From f157510541376c87beff37a01b09b4cf9fefbfca Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 27 Jul 2011 13:40:29 +0530 Subject: [PATCH] backups fix --- cgi-bin/webnotes/defs_template.py | 13 +++++++++++++ cgi-bin/webnotes/utils/backups.py | 13 +++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cgi-bin/webnotes/defs_template.py b/cgi-bin/webnotes/defs_template.py index 67d849d7fe..80e3113129 100644 --- a/cgi-bin/webnotes/defs_template.py +++ b/cgi-bin/webnotes/defs_template.py @@ -84,4 +84,17 @@ log_level = 'logging.INFO' log_file_size = 5000 log_file_backup_count = 5 +# +# Backup Settings +# +# where the dumps will be stored +backup_path = '/backups' + +# where the latest dump will show up so that it can be +# downloaded from the web +backup_link_path = '/var/www/wnframework/backups' + +# url to be emailed to the "System Manager" Role to download +# the backup +backup_url = 'http://localhost/backups' diff --git a/cgi-bin/webnotes/utils/backups.py b/cgi-bin/webnotes/utils/backups.py index 903683c196..d69c9a00e1 100644 --- a/cgi-bin/webnotes/utils/backups.py +++ b/cgi-bin/webnotes/utils/backups.py @@ -1,5 +1,10 @@ """ - This module handles the On Demand Backup utility + This module handles the On Demand Backup utility + + To setup in defs set: + backup_path: path where backups will be taken (for eg /backups) + backup_link_path: download link for backups (eg /var/www/wnframework/backups) + backup_url: base url of the backup folder (eg http://mysite.com/backups) """ #Imports import os, webnotes @@ -23,7 +28,7 @@ class BackupGenerator: self.user = user self.password = password self.db_file_name = db_file_name and db_file_name \ - or (backup_path + db_name + ".sql.gz") + or (os.path.join(backup_path, db_name + ".sql.gz")) def take_dump(self): """ @@ -47,7 +52,7 @@ class BackupGenerator: os.system("""cp -f %(src_file)s %(dest_file)s""" % \ {"src_file":self.db_file_name, - "dest_file":(backup_link_path + random_name)}) + "dest_file":os.path.join(backup_link_path, random_name)}) if verbose: print "file copied" return random_name @@ -71,7 +76,7 @@ class BackupGenerator: """ Sends the link to backup file located at erpnext/backups """ - file_url = backup_url + backup_file + file_url = os.path.join(backup_url, backup_file) from webnotes.utils.email_lib import sendmail recipient_list = self.get_recipients()