Скрипт бэкапа сайта и базы данных

как временное решение скрипт на баше, чтобы делать бэкапы

#!/bin/sh

basedir="/dir/to/backup"
name="sitename"
wwwdir="sitepath"
sqlbase="basename"
sqllogin="username"
sqlpwd="password"

curDate=$(printf `date "+%Y-%m-%d"`) #получаем текущую дату
dumpDir=${name}${curDate}
cd ${basedir}
if [[ $(find . -type d -name ${dumpDir}) -eq $(${basedir}"/"${dumpDir})]]
then
printf "This directory "${baseDir}${dumpDir}" already exist"
else
mkdir ${dumpDir}
fi
cd ${baseDir}${dumpDir}

tar czPf ${dumpDir}.tar.gz ${wwwdir}
/usr/local/bin/mysqldump -hlocalhost -u${sqllogin} -p${sqlpwd} sqlbase > ${dumpDir}.sql
tar czf ${dumpDir}.sql.tar.gz ${dumpDir}.sql
unlink ${dumpDir}.sql
if [[ $(find . -name "CHECKSUM.MD5") -eq $(${basedir}${dumpDir}"/CHECKSUM.MD5")]]
then
unlink "CHECKSUM.MD5"
fi
md5 ${dumpDir}.tar.gz ${dumpDir}.sql.tar.gz >> "CHECKSUM.MD5"
chmod ugo+w . *

и скрипт на питоне, чтобы их забирать на другую машину

#if __name__ == '__main__':
#    print ('not main module')
#    exit()

import os
import re
import sys
import datetime
import time
import glob
import linecache
import hashlib
import shutil
from datetime import date
from ftplib import FTP

fromsite = r'example.com'          #ftp
ftpuser = r'ftpuser'           #user
ftppassword = r'ftppassword'  #pass 
todir = r'/dir/backup/'               #dir on ftp from server
dir = r'D:\backup'             #dir to save files from local 
now = datetime.datetime.now()                               
year, month, day, hour, minutes, sec, wday, yday, isdst = now.timetuple() 
today = "%4d-%02d-%02d" % (year,month,day)
pacients = [{'name': 'site1.com', 'remoteList': ''}, {'name': 'site2.com', 'remoteList': ''}]
#[_print(filename) for filename in glob.glob("c:\\*.sys")]

def prepareDate(temp):
    temp = temp.split('.')[-1].split('-')
    return datetime.date(int(temp[0]), int(temp[1]), int(temp[2]))

def download(localPath, fileName):
#   try:
        fh = open(fileName, 'wb')
        print ('Transfer filename %s...' % fileName)
        connection.retrbinary('RETR ' + fileName, fh.write)  #transfer file
        fh.close()

#    except:     
#        print ('error transfer filename %s!' % fileName)
#        time.sleep(60)
#        download(localPath, fileName)

def md5(pathDir):
    checkList = {re.search(r'\(([^\)]+)', line).group(1): re.search(r'=\s*(.*)\n*$',line).group(1) for line in open(os.path.join(pathDir, "CHECKSUM.MD5"), "r").readlines()}
    for element in checkList.items():
        m = hashlib.md5()
        with open(os.path.join(pathDir, element[0]), "rb") as fh:
            m.update(fh.read())
        if m.hexdigest() != element[1]:
            download(pathDir, element[0])

def delCat(folders):
#    connection.cwd(todir)
    if len(folders)>8:
        for num in range(0, len(folders)-8):
            try:
                connection.cwd(folders[num])
                [connection.delete(file)for file in connection.nlst()]
                connection.cwd(todir)
                connection.rmd(folders[num])
                print(folders[num], 'delete')
            except: 
                time.sleep(60)
                print('error del %s' % folders[num])
                delCat(folders)
#                connection.quit()

"""connect"""
connected = None
timer = 0
while not connected:
    timer = timer + 1
    try:
        connection = FTP(fromsite, ftpuser, ftppassword)
        print ('connection with %s' % fromsite)
        connection.cwd(todir)
        connected = 1
    except:
        connected = None
        print('error connect %s' % fromsite)
    if timer > 4:
        exit() 

"""create list"""
for pacient in pacients:
    pacient['remoteList'] = sorted(list(set(x.split('/')[0] for x in sorted(connection.nlst(pacient['name'] + '*')))))
    pacient['localList'] = glob.glob(os.path.join(dir, pacient['name']) + '*')
    pacient['localList'] = sorted([os.path.basename(x) for x in pacient['localList']])

"""check folders"""
for pacient in pacients:
    if not len(pacient['localList'])  or (prepareDate(pacient['localList'][-1])<prepareDate(pacient['remoteList'][-1])):
        a = os.path.join(dir, pacient['remoteList'][-1])
        connection.cwd(os.path.join(todir, pacient['remoteList'][-1]))
        if not os.path.exists(a):
            os.mkdir(a)
        os.chdir(a)
        for file in connection.nlst():
            download(a, file)

connection.quit()

"""check md5"""
for pacient in pacients:
    md5(os.path.join(dir, pacient['remoteList'][-1]))            

connected = None
while not connected:
    try:
        connection = FTP(fromsite, ftpuser, ftppassword)
        print ('connection with %s' % fromsite)
        connection.cwd(todir)
        connected = 1
    except:
        connected = None
        print('error connect %s' % fromsite)

"""delete old"""
#for pacient in pacients:
#    delCat(pacient['remoteList'])

connection.quit()
print('connection quit')