def test_sync_sources_override(self): conf = Config('test-resources/rbak.conf') ex = PushExecutor() bak = Backuper(conf, source_names='git', executor=ex, dry_run=True) bak.sync() cmds = [ '/bin/mount -L extbak2t /mnt/extbak2t', 'rsync -rltpgoDuv -n /opt/var/git/ /mnt/extbak2t/bak/git', 'rsync -rltpgoDuv -n /opt/var/git/ /opt/hd1/git' ] self.assertEqual(cmds, ex.cmds)
def test_mount(self): conf = Config('test-resources/rbak.conf') ex = PushExecutor() bak = Backuper(conf, executor=ex, dry_run=True) targ = bak.targets[0] targ.mount() self.assertEqual(['/bin/mount -L extbak2t /mnt/extbak2t'], ex.cmds)
def test_read_targs_path(self): conf = Config('test-resources/rbak.conf') bak = Backuper(conf, dry_run=True) targ = bak.targets[1] self.assertEqual('hdbak1', targ.name) self.assertEqual('/opt/hd1', targ.path) self.assertEqual('', targ.backup_dir) self.assertEqual('/opt/hd1', targ.backup_path)
def __init__(self): dry_run_op = [ '-d', '--dryrun', False, { 'dest': 'dry_run', 'action': 'store_true', 'default': False, 'help': 'dry run to not actually connect, but act like it' } ] sources_op = [ '-n', '--sources', False, { 'dest': 'source_names', 'help': 'override the sources property in the config' } ] cnf = { 'executors': [{ 'name': 'backup', 'executor': lambda params: Backuper(**params), 'actions': [{ 'name': 'info', 'doc': 'print backup configuration information' }, { 'name': 'backup', 'meth': 'sync', 'doc': 'run the backup', 'opts': [dry_run_op, sources_op] }, { 'name': 'mount', 'meth': 'mount_all', 'doc': 'mount all targets', 'opts': [dry_run_op] }, { 'name': 'umount', 'meth': 'umount_all', 'doc': 'un-mount all targets', 'opts': [dry_run_op] }] }], # uncomment to add a configparse (ini format) configuration file 'config_option': { 'name': 'config', 'opt': [ '-c', '--config', False, { 'dest': 'config', 'metavar': 'FILE', 'default': '/etc/rbak.conf', 'help': 'configuration file' } ] }, 'whine': 1 } super(ConfAppCommandLine, self).__init__(cnf, version=VERSION)
def test_read_sources(self): conf = Config('test-resources/rbak.conf') bak = Backuper(conf, dry_run=True) sources = bak.sources self.assertEqual(2, len(sources)) self.assertEqual('/opt/var/git', sources[0].path) self.assertEqual('git', sources[0].basename) self.assertEqual('/opt/var/svn', sources[1].path) self.assertEqual('other/svndir', sources[1].basename)
def test_try_mount(self): conf = Config('test-resources/rbak.conf') bak = Backuper(conf, dry_run=False) targ = bak.targets[1] def mfn(): targ.mount() self.assertRaises(ValueError, mfn)
def test_read_targs(self): conf = Config('test-resources/rbak.conf') bak = Backuper(conf, dry_run=True) targs = bak.targets self.assertEqual(2, len(targs)) targ = targs[0] self.assertEqual('extbak2t', targ.name) self.assertEqual('/mnt/extbak2t', targ.path) self.assertEqual('bak', targ.backup_dir) self.assertEqual('/mnt/extbak2t/bak', targ.backup_path)