Skip to content
Snippets Groups Projects
Commit 038644cb authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Fixed crash because of an invalid setup.

parent 8ddd1431
No related branches found
No related tags found
No related merge requests found
...@@ -5,24 +5,26 @@ import utils ...@@ -5,24 +5,26 @@ import utils
import socket import socket
import os import os
CROND_TEMPLATE = '''# https://github.com/laurent22/rsync-time-backup
0 22 * * * /usr/local/sbin/rsync_tmbackup.sh /etc root@{backup_server}:/backup/{hostname}/etc
0 22 * * * /usr/local/sbin/rsync_tmbackup.sh /home root@{backup_server}:/backup/{hostname}/home
'''
cmds = [ def setup(interactive=True):
'cp rsync_tmbackup.sh /usr/local/sbin', CROND_TEMPLATE = '''# https://github.com/laurent22/rsync-time-backup
'cp /tmp/backup.cron /etc/cron.d/', 0 22 * * * /usr/local/sbin/rsync_tmbackup.sh /etc root@{backup_server}:/backup/{hostname}/etc
] 0 22 * * * /usr/local/sbin/rsync_tmbackup.sh /home root@{backup_server}:/backup/{hostname}/home
'''
server = utils.get_conf('BACKUP_SERVER', '') cmds = [
if server: 'cp rsync_tmbackup.sh /usr/local/sbin',
if os.path.exists('/etc/cron.d/backup.cron'): 'cp /tmp/backup.cron /etc/cron.d/',
print('/etc/cron.d/backup.cron already here, skipping install') ]
server = utils.get_conf('BACKUP_SERVER', '')
if server:
if os.path.exists('/etc/cron.d/backup.cron'):
print('/etc/cron.d/backup.cron already here, skipping install')
else:
with open('/tmp/backup.cron', 'w') as f:
CROND = CROND_TEMPLATE.format(backup_server=server, hostname=socket.gethostname())
f.write(CROND)
utils.run_commands(cmds)
else: else:
with open('/tmp/backup.cron', 'w') as f: print('Missing BACKUP_SERVER in conf')
CROND = CROND_TEMPLATE.format(backup_server=server, hostname=socket.gethostname())
f.write(CROND)
utils.run_commands(cmds)
else:
print('Missing BACKUP_SERVER in conf')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment