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]
OnCalendar=*-*-* 01:59:00
Persistent=true
Unit=djing.service
[Install]

1
systemd_units/djing_backup.timer

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

7
systemd_units/webdav_backup.py

@ -9,14 +9,15 @@ options = {
'webdav_login': "YANDEX USERNAME",
'webdav_password': "YANDEX PASSWORD"
}
REMOTE_DIR = 'DjingBackups'
def remove_old_files(border_time: datetime, client):
# 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')
if fdate < border_time:
del_fname = os.path.join('ISBackups', file)
del_fname = os.path.join(REMOTE_DIR, file)
client.clean(del_fname)
print("rm %s" % del_fname)
@ -30,7 +31,7 @@ if __name__ == '__main__':
remove_old_files(border_time, client)
else:
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)
)
except wc.WebDavException as we:

Loading…
Cancel
Save