Here is a remote backup script I've installed here as a three cron jobs
running at different frequencies. (rsync >=3 required)
So far, it seems to work as intended.
Is there anything we should do to improve this?


#!/usr/bin/env python
"""
Backup remote Durus database.
This assumes that you have configured your system so that
this user can ssh to the remote system without entering a
password.
"""
from commands import getoutput
import sys, os
try:
    remote_host, remote_path, local_path = sys.argv[1:]
except:
    print("%s <remote_host> <remote_path> <local_path>" % sys.argv[0])
    raise SystemExit

local_prepackstat_path = local_path + '.prepackstat'
local_prepackstat = ''

rsync_flag = '--append-verify'

if os.path.exists(local_prepackstat_path):
    local_prepackstat = open(local_prepackstat_path).read()

remote_prepackstat = getoutput("ssh %s stat -t %s.prepack" % (remote_host, remote_path))
if local_prepackstat:
    if local_prepackstat == remote_prepackstat:
        rsync_flag = '--append'
f = open(local_prepackstat_path, 'w')
f.write(remote_prepackstat)
f.close()

command = 'rsync %s --rsh=ssh %s:%s %s' % (
        rsync_flag, remote_host, remote_path, local_path)
#print(command)
os.system(command)
_______________________________________________
QP mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp

Reply via email to