Browse Source

fix units

devel
Dmitry Novikov 6 years ago
parent
commit
591c6c0172
  1. 1
      systemd_units/djing.timer
  2. 1
      systemd_units/djing_backup.timer
  3. 7
      systemd_units/webdav_backup.py

1
systemd_units/djing.timer

@ -3,7 +3,6 @@ Description=Run every night a job for djing
[Timer] [Timer]
OnCalendar=*-*-* 01:59:00 OnCalendar=*-*-* 01:59:00
Persistent=true
Unit=djing.service Unit=djing.service
[Install] [Install]

1
systemd_units/djing_backup.timer

@ -3,7 +3,6 @@ Description=Run backup periodically
[Timer] [Timer]
OnCalendar=*-*-* 8,12,14,16,19,23:15:0 OnCalendar=*-*-* 8,12,14,16,19,23:15:0
Persistent=true
Unit=djing_backup.service Unit=djing_backup.service
[Install] [Install]

7
systemd_units/webdav_backup.py

@ -9,14 +9,15 @@ options = {
'webdav_login': "YANDEX USERNAME", 'webdav_login': "YANDEX USERNAME",
'webdav_password': "YANDEX PASSWORD" 'webdav_password': "YANDEX PASSWORD"
} }
REMOTE_DIR = 'DjingBackups'
def remove_old_files(border_time: datetime, client): def remove_old_files(border_time: datetime, client):
# files that older than border_time will be removed # files that older than border_time will be removed
for file in client.list('ISBackups'):
for file in client.list(REMOTE_DIR):
fdate = datetime.strptime(file, 'djing%Y-%m-%d_%H.%M.%S.sql.gz') fdate = datetime.strptime(file, 'djing%Y-%m-%d_%H.%M.%S.sql.gz')
if fdate < border_time: if fdate < border_time:
del_fname = os.path.join('ISBackups', file)
del_fname = os.path.join(REMOTE_DIR, file)
client.clean(del_fname) client.clean(del_fname)
print("rm %s" % del_fname) print("rm %s" % del_fname)
@ -30,7 +31,7 @@ if __name__ == '__main__':
remove_old_files(border_time, client) remove_old_files(border_time, client)
else: else:
client.upload_sync( client.upload_sync(
remote_path=os.path.join('ISBackups', reqfile),
remote_path=os.path.join(REMOTE_DIR, reqfile),
local_path=os.path.join(os.path.sep, 'var', 'backups', reqfile) local_path=os.path.join(os.path.sep, 'var', 'backups', reqfile)
) )
except wc.WebDavException as we: except wc.WebDavException as we:

Loading…
Cancel
Save