Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 72 lines (56 sloc) 1.93 KB
import sys
import os
import config
import shutil
from datetime import date, datetime
from provider import processProviders as provider
from sql import processSql as sql
from filesystem import processFS as fs
backupName = str(;
sqlTmpDir = config.tmpDir + "/sql"
# Set the backup type
backupType = sys.argv[1]
def main():
# Create the tmp backup directories
# Start off our log
logWrite("********** START OF LOG **********")
logWrite("Backup process started.")
# Set the SQL Backup path, and dump the backup
logWrite("Creating database backup...")
sqlStatus = sql(sqlTmpDir, backupName)
# Process the filesystem backups
logWrite("Creating filesystem backup...")
fsStatus = fs(sqlTmpDir, sqlStatus['enabled'], backupName, config.tmpDir)
# Push file to backup destination
logWrite("Pushing backup to configured provider(s)...")
pushStatus = provider(backupType, fsStatus['file'], config.tmpDir)
# If the backup push was successful, delete the tmp backup folder.
if pushStatus['status'] == True:
# Delete the DB Backup file. Since this is added to the archive, no need to keep it if the archive
# copy fails.
logWrite("Deleting temporary backup files.")
# remove the sql backup directory, since it's already in the archive, and add the failure to the log
logWrite("There was an issue pushing the local backup.\n Backup is located in " + config.tmpDir)
logWrite("Backup process complete.")
logWrite("********** END OF LOG **********\n\n")
def currentTime():
time =
return str(time)
def logWrite(string):
log = open(config.logFile,"aw")
log.write(currentTime() + ": " + string + "\n")
def checkDir(d):
if not os.path.exists(d):
if __name__ == "__main__":
Jump to Line
Something went wrong with that request. Please try again.