Added symlink/dereference and modified lvm auto guess options
The following options are added/modified: - --dereference-symlink {'none', 'soft', 'hard', 'all'}: Follow Hard and soft links and archive and dump the files they refer to according the choise option set. - --lvm-auto-snap: now takes as argument the path you want to guess for the lvm group and volume name Also few types where removed. Dependencies are also update, as now pymongo and mysqldb module needs to be installed Change-Id: I99b780ff7b34dd85162634855357e1785db0e893
This commit is contained in:
parent
c90076b4d0
commit
e46660a040
|
@ -181,7 +181,7 @@ adminui.git::
|
|||
--backup-name adminui.git
|
||||
--restore-from-host git-HP-DL380-host-001 --restore-abs-path
|
||||
/home/git/repositories/adminui.git/
|
||||
--restore-from-date "23-05-2014T23:23:23"
|
||||
--restore-from-date "2014-05-23T23:23:23"
|
||||
|
||||
MySQL restore:
|
||||
|
||||
|
@ -194,7 +194,7 @@ Execute Restore::
|
|||
|
||||
$ sudo freezerc --container foobar-container-2
|
||||
--backup-name mysq-prod --restore-from-host db-HP-DL380-host-001
|
||||
--restore-abs-path /var/lib/mysql --restore-from-date "23-05-2014T23:23:23"
|
||||
--restore-abs-path /var/lib/mysql --restore-from-date "2014-05-23T23:23:23"
|
||||
|
||||
And finally restart mysql::
|
||||
|
||||
|
@ -204,7 +204,7 @@ Execute a MongoDB restore of the backup name mongobigdata::
|
|||
|
||||
$ sudo freezerc --container foobar-container-2 --backup-name mongobigdata
|
||||
--restore-from-host db-HP-DL380-host-001 --restore-abs-path
|
||||
/var/lib/mongo --restore-from-date "23-05-2014T23:23:23"
|
||||
/var/lib/mongo --restore-from-date "2014-05-23T23:23:23"
|
||||
|
||||
Architecture
|
||||
============
|
||||
|
@ -354,4 +354,4 @@ tar\_metadata\_backupname\_hostname\_timestamp\_backuplevel
|
|||
|
||||
The hostname of the node where the Freezer perform the backup. This meta
|
||||
data is important to identify a backup with a specific node, thus avoid
|
||||
possible confusion and associate backup to the wrong node.
|
||||
possible confusion and associate backup to the wrong node.
|
||||
|
|
|
@ -26,7 +26,6 @@ import argparse
|
|||
import distutils.spawn as distspawn
|
||||
import os
|
||||
import logging
|
||||
import pkg_resources
|
||||
|
||||
|
||||
def backup_arguments():
|
||||
|
@ -69,9 +68,9 @@ def backup_arguments():
|
|||
help="The file name used to save the object on your local disk and\
|
||||
upload file in swift", dest='dst_file', default=False)
|
||||
arg_parser.add_argument(
|
||||
'--lvm-auto-snap', action='store_true',
|
||||
help=("Automatically guess the volume group and volume name. "
|
||||
"Option --file-to-backup is mandatory"),
|
||||
'--lvm-auto-snap', action='store',
|
||||
help=("Automatically guess the volume group and volume name for "
|
||||
"given PATH."),
|
||||
dest='lvm_auto_snap',
|
||||
default=False)
|
||||
arg_parser.add_argument(
|
||||
|
@ -157,6 +156,12 @@ def backup_arguments():
|
|||
given as a PATTERN.Ex: --exclude '*.log' will exclude any file with \
|
||||
name ending with .log. Default no exclude", dest='exclude',
|
||||
default=False)
|
||||
arg_parser.add_argument(
|
||||
'--dereference-symlink', choices=['none', 'soft', 'hard', 'all'],
|
||||
help=(
|
||||
"Follow hard and soft links and archive and dump the files they "
|
||||
" refer to. Default False."),
|
||||
dest='dereference_symlink', default='none')
|
||||
arg_parser.add_argument(
|
||||
'-U', '--upload', action='store_true',
|
||||
help="Upload to Swift the destination file passed to the -d option.\
|
||||
|
@ -173,9 +178,8 @@ def backup_arguments():
|
|||
dest='max_seg_size', type=int, default=134217728)
|
||||
arg_parser.add_argument(
|
||||
'--restore-abs-path', action='store',
|
||||
help='Set the absolute path where you want your data restored. \
|
||||
option --restore need to be set along with --get-object in order \
|
||||
to execute data restore. Default False.',
|
||||
help=('Set the absolute path where you want your data restored. '
|
||||
'Default False.'),
|
||||
dest='restore_abs_path', default=False)
|
||||
arg_parser.add_argument(
|
||||
'--restore-from-host', action='store',
|
||||
|
@ -246,7 +250,6 @@ def backup_arguments():
|
|||
backup_args.__dict__['mysql_db_inst'] = ''
|
||||
|
||||
# Freezer version
|
||||
backup_args.__dict__['__version__'] = pkg_resources.require(
|
||||
'freezer')[0].version
|
||||
backup_args.__dict__['__version__'] = '1.0.9-2'
|
||||
|
||||
return backup_args, arg_parser
|
||||
|
|
|
@ -217,7 +217,7 @@ def get_lvm_info(backup_opt_dict):
|
|||
and lvm_volgroup with respective values
|
||||
"""
|
||||
|
||||
mount_point_path = get_mount_from_path(backup_opt_dict.src_file)
|
||||
mount_point_path = get_mount_from_path(backup_opt_dict.lvm_auto_snap)
|
||||
with open('/proc/mounts', 'r') as mount_fd:
|
||||
mount_points = mount_fd.readlines()
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ def restore_fs_sort_obj(backup_opt_dict):
|
|||
|
||||
# Backups are looped from the last element of the list going
|
||||
# backwards, as we want to restore starting from the oldest object
|
||||
write_pipe, read_pipe = Pipe()
|
||||
for backup in closest_backup_list[::-1]:
|
||||
write_pipe, read_pipe = Pipe()
|
||||
process_stream = Process(
|
||||
target=object_to_stream, args=(
|
||||
backup_opt_dict, write_pipe, backup,))
|
||||
|
|
|
@ -34,7 +34,7 @@ import time
|
|||
def tar_restore(backup_opt_dict, read_pipe):
|
||||
"""
|
||||
Restore the provided file into backup_opt_dict.restore_abs_path
|
||||
Descrypt the file if backup_opt_dict.encrypt_pass_file key is provided
|
||||
Decrypt the file if backup_opt_dict.encrypt_pass_file key is provided
|
||||
"""
|
||||
|
||||
# Validate mandatory arguments
|
||||
|
@ -157,13 +157,26 @@ def gen_tar_command(
|
|||
logging.info('[*] Backup started for: {0} \
|
||||
'.format(opt_dict.src_file))
|
||||
|
||||
# Tar option for default behavoir. Please refer to man tar to have
|
||||
# Tar option for default behavior. Please refer to man tar to have
|
||||
# a better options explanation
|
||||
tar_command = ' {0} --create -z --warning=none \
|
||||
--dereference --hard-dereference --no-check-device --one-file-system \
|
||||
--no-check-device --one-file-system \
|
||||
--preserve-permissions --same-owner --seek \
|
||||
--ignore-failed-read '.format(opt_dict.tar_path)
|
||||
|
||||
# Dereference hard and soft links according option choices.
|
||||
# 'soft' dereference soft links, 'hard' dereference hardlinks,
|
||||
# 'all' dereference both. Defaul 'none'.
|
||||
if opt_dict.dereference_symlink == 'soft':
|
||||
tar_command = ' {0} --dereference '.format(
|
||||
tar_command)
|
||||
if opt_dict.dereference_symlink == 'hard':
|
||||
tar_command = ' {0} --hard-dereference '.format(
|
||||
tar_command)
|
||||
if opt_dict.dereference_symlink == 'all':
|
||||
tar_command = ' {0} --hard-dereference --dereference '.format(
|
||||
tar_command)
|
||||
|
||||
file_name = add_host_name_ts_level(opt_dict, time_stamp)
|
||||
meta_data_backup_file = u'tar_metadata_{0}'.format(file_name)
|
||||
# Incremental backup section
|
||||
|
|
|
@ -82,7 +82,7 @@ def gen_manifest_meta(
|
|||
manifest_meta_dict['x-object-meta-remove-backup-older-than-days'] = ''
|
||||
if backup_opt_dict.remove_older_than is not False:
|
||||
manifest_meta_dict['x-object-meta-remove-backup-older-than-days']\
|
||||
= backup_opt_dict.remove_older_than
|
||||
= '{0}'.format(backup_opt_dict.remove_older_than)
|
||||
manifest_meta_dict['x-object-meta-hostname'] = backup_opt_dict.hostname
|
||||
manifest_meta_dict['x-object-meta-segments-size-bytes'] = \
|
||||
str(backup_opt_dict.max_seg_size)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
python-swiftclient>=2.0.3
|
||||
python-swiftclient>=1.6.0
|
||||
python-keystoneclient>=0.8.0
|
||||
argparse>=1.2.1
|
||||
docutils>=0.8.1
|
||||
mysql-python
|
||||
pymongo
|
||||
|
||||
[testing]
|
||||
pytest
|
||||
|
|
10
setup.py
10
setup.py
|
@ -32,7 +32,7 @@ def read(*filenames, **kwargs):
|
|||
|
||||
setup(
|
||||
name='freezer',
|
||||
version='1.0.9',
|
||||
version='1.0.9-2',
|
||||
url='http://sourceforge.net/projects/openstack-freezer/',
|
||||
license='Apache Software License',
|
||||
author='Fausto Marzi, Ryszard Chojnacki, Emil Dimitrov',
|
||||
|
@ -70,9 +70,11 @@ setup(
|
|||
'Topic :: System :: Archiving',
|
||||
],
|
||||
install_requires=[
|
||||
'python-swiftclient>=2.0.3',
|
||||
'python-keystoneclient>=0.8.0',
|
||||
'argparse>=1.2.1'],
|
||||
'python-swiftclient>=1.6.0',
|
||||
'python-keystoneclient>=0.7.0',
|
||||
'mysql-python',
|
||||
'pymongo',
|
||||
'docutils>=0.8.1'],
|
||||
extras_require={
|
||||
'testing': ['pytest', 'flake8'],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue