Fix for skip + Example adaptions

This commit is contained in:
Dirk Alders 2021-01-16 09:19:21 +01:00
parent 81f7cf4b2e
commit bb0f44652e
4 changed files with 44 additions and 16 deletions

22
.gitignore vendored
View File

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

View File

@ -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']

View File

@ -4,22 +4,24 @@ import sys
backup = False
hosts = ['ahorn', 'erle', 'linde']
__basepath__ = '/user_data'
__basepath__ = '/usr/data'
entries = (
('dirk@%s:/user_data/bin', os.path.join(__basepath__, 'bin'), None),
('dirk@%s:/user_data/data', os.path.join(__basepath__, 'data'), None),
('dirk@%s:/user_data/static_data', os.path.join(__basepath__, 'static_data'), ['Audio', 'timeshift', 'lost+found']),
('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/items'
mount_mockery_audio_localpath = os.path.join(__basepath__, 'static_data', 'dirk', 'Audio')
mount_mockery_audio_remotepath = 'root@mount-mockery.de:/data/audio'
mount_mockery_audio_localpath = os.path.join(__basepath__, 'dirk', 'Audio')

7
mysync
View File

@ -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
@ -70,7 +70,10 @@ def rsync_command(**kwargs):
skip = kwargs.get(PROP_SKIP)
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)