Compare commits

...

2 Commits

Author SHA1 Message Date
b0b417fd57 Merge 2021-01-16 09:24:27 +01:00
bb0f44652e Fix for skip + Example adaptions 2021-01-16 09:19:21 +01:00
4 changed files with 39 additions and 13 deletions

19
.gitignore vendored

@ -1,6 +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
# Byte-compiled / optimized / DLL files
__pycache__/

@ -2,13 +2,14 @@ import os
import sys
backup = True
backup_basepath = '/data/backup/ahorn'
host = 'erle'
backup_basepath = '/data/backup/data'
installations = ['mint', 'kubuntu', 'openSuSE']
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'))
user_data_remotepath = 'dirk@ahorn:/user_data'
user_data_localpath = 'user_data'
user_data_skip = ['static_data']
data_remotepath = 'dirk@%s:/usr/data' % host
data_localpath = 'usr/data'
data_skip = ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos']

@ -3,22 +3,25 @@ import sys
backup = False
hosts = ['ahorn', 'buche', 'erle', 'linde']
hosts = ['ahorn', 'erle', 'linde']
__basepath__ = '/usr/data'
entries = (
('dirk@%s:/usr/data', __basepath__, None),
('dirk@%s:/usr/data', __basepath__, ['lost+found']),
('dirk@%s:/usr/data', __basepath__, ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/Downloads', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos']),
('dirk@%s:/home', '/home', None),
)
for host in hosts:
for remote, local, skip in entries:
setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_remotepath', remote % host)
setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_localpath', local)
name = os.path.basename(local)
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'
mount_mockery_audio_localpath = os.path.join(__basepath__, 'dirk', 'Audio')

7
mysync

@ -10,7 +10,7 @@ import subprocess
DEBUG = False
RSYNC_REMOTE_COMMAND = 'sudo rsync'
RSYNC_REMOTE_COMMAND = 'rsync'
TIME_FORMAT = "%Y-%m-%d_%H-%M-%S"
try:
basepath = config.backup_basepath
@ -73,7 +73,10 @@ def rsync_command(**kwargs):
else:
cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', '--rsync-path="%s"' % RSYNC_REMOTE_COMMAND, remotepath, localpath]
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):
return 'mkdir -p %s && ' % localpath + ' '.join(cmd_l)
return ' '.join(cmd_l)