Fix for skip + Example adaptions
This commit is contained in:
parent
81f7cf4b2e
commit
bb0f44652e
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,3 +1,25 @@
|
|||||||
|
config.py
|
||||||
|
|
||||||
|
# ---> Eclipse
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.settings
|
||||||
|
|
||||||
|
# ---> Linux
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
@ -2,13 +2,14 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
backup = True
|
backup = True
|
||||||
backup_basepath = '/data/backup/ahorn'
|
host = 'erle'
|
||||||
|
backup_basepath = '/data/backup/data'
|
||||||
|
|
||||||
installations = ['mint', 'kubuntu', 'openSuSE']
|
installations = ['mint', 'kubuntu', 'openSuSE']
|
||||||
for installation in installations:
|
for installation in installations:
|
||||||
setattr(sys.modules[__name__], 'home_%s_remotepath' % installation, 'dirk@ahorn:/home')
|
setattr(sys.modules[__name__], 'home_%s_remotepath' % installation, 'dirk@%s:/home' % host)
|
||||||
setattr(sys.modules[__name__], 'home_%s_localpath' % installation, os.path.join(installation, 'home'))
|
setattr(sys.modules[__name__], 'home_%s_localpath' % installation, os.path.join(installation, 'home'))
|
||||||
|
|
||||||
user_data_remotepath = 'dirk@ahorn:/user_data'
|
data_remotepath = 'dirk@%s:/usr/data' % host
|
||||||
user_data_localpath = 'user_data'
|
data_localpath = 'usr/data'
|
||||||
user_data_skip = ['static_data']
|
data_skip = ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos']
|
||||||
|
@ -4,22 +4,24 @@ import sys
|
|||||||
backup = False
|
backup = False
|
||||||
|
|
||||||
hosts = ['ahorn', 'erle', 'linde']
|
hosts = ['ahorn', 'erle', 'linde']
|
||||||
__basepath__ = '/user_data'
|
__basepath__ = '/usr/data'
|
||||||
entries = (
|
entries = (
|
||||||
('dirk@%s:/user_data/bin', os.path.join(__basepath__, 'bin'), None),
|
('dirk@%s:/usr/data', __basepath__, ['lost+found']),
|
||||||
('dirk@%s:/user_data/data', os.path.join(__basepath__, 'data'), None),
|
('dirk@%s:/usr/data', __basepath__, ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/Downloads', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos']),
|
||||||
('dirk@%s:/user_data/static_data', os.path.join(__basepath__, 'static_data'), ['Audio', 'timeshift', 'lost+found']),
|
|
||||||
('dirk@%s:/home', '/home', None),
|
('dirk@%s:/home', '/home', None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
for remote, local, skip in entries:
|
for remote, local, skip in entries:
|
||||||
setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_remotepath', remote % host)
|
name = os.path.basename(local)
|
||||||
setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_localpath', local)
|
|
||||||
if skip is not None:
|
if skip is not None:
|
||||||
setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_skip', skip)
|
if len(skip) > 1:
|
||||||
|
name += '_short'
|
||||||
|
setattr(sys.modules[__name__], host + '_' + name + '_skip', skip)
|
||||||
|
setattr(sys.modules[__name__], host + '_' + name + '_remotepath', remote % host)
|
||||||
|
setattr(sys.modules[__name__], host + '_' + name + '_localpath', local)
|
||||||
|
|
||||||
|
|
||||||
mount_mockery_audio_remotepath = 'root@mount-mockery.de:/data/audio/items'
|
mount_mockery_audio_remotepath = 'root@mount-mockery.de:/data/audio'
|
||||||
mount_mockery_audio_localpath = os.path.join(__basepath__, 'static_data', 'dirk', 'Audio')
|
mount_mockery_audio_localpath = os.path.join(__basepath__, 'dirk', 'Audio')
|
||||||
|
7
mysync
7
mysync
@ -10,7 +10,7 @@ import subprocess
|
|||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
RSYNC_REMOTE_COMMAND = 'sudo rsync'
|
RSYNC_REMOTE_COMMAND = 'rsync'
|
||||||
TIME_FORMAT = "%Y-%m-%d_%H-%M-%S"
|
TIME_FORMAT = "%Y-%m-%d_%H-%M-%S"
|
||||||
try:
|
try:
|
||||||
basepath = config.backup_basepath
|
basepath = config.backup_basepath
|
||||||
@ -70,7 +70,10 @@ def rsync_command(**kwargs):
|
|||||||
skip = kwargs.get(PROP_SKIP)
|
skip = kwargs.get(PROP_SKIP)
|
||||||
cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', '--rsync-path="%s"' % RSYNC_REMOTE_COMMAND, remotepath, localpath]
|
cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', '--rsync-path="%s"' % RSYNC_REMOTE_COMMAND, remotepath, localpath]
|
||||||
if skip is not None:
|
if skip is not None:
|
||||||
cmd_l.append('--exclude=%s' % ','.join(skip))
|
for skip_dir in skip:
|
||||||
|
if not skip_dir.endswith('/'):
|
||||||
|
skip_dir += '/'
|
||||||
|
cmd_l.append('--exclude=%s' % skip_dir)
|
||||||
if not os.path.exists(localpath):
|
if not os.path.exists(localpath):
|
||||||
return 'mkdir -p %s && ' % localpath + ' '.join(cmd_l)
|
return 'mkdir -p %s && ' % localpath + ' '.join(cmd_l)
|
||||||
return ' '.join(cmd_l)
|
return ' '.join(cmd_l)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user