From f157510541376c87beff37a01b09b4cf9fefbfca Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 27 Jul 2011 13:40:29 +0530 Subject: [PATCH 1/3] 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() From 517149a796053ed1f1af1136796e0f5607d903c5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 27 Jul 2011 13:52:08 +0530 Subject: [PATCH 2/3] backup fix --- cgi-bin/webnotes/utils/backups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/utils/backups.py b/cgi-bin/webnotes/utils/backups.py index d69c9a00e1..b78d75c621 100644 --- a/cgi-bin/webnotes/utils/backups.py +++ b/cgi-bin/webnotes/utils/backups.py @@ -137,7 +137,7 @@ def delete_temp_backups(): """ file_list = os.listdir(backup_link_path) for this_file in file_list: - this_file_path = backup_link_path + this_file + this_file_path = os.path.join(backup_link_path, this_file) if is_file_old(this_file_path): os.remove(this_file_path) From 626bdd8b50de58e11fb8554fa8eb82576223552d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 27 Jul 2011 13:54:54 +0530 Subject: [PATCH 3/3] backup fix --- cgi-bin/webnotes/utils/backups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/utils/backups.py b/cgi-bin/webnotes/utils/backups.py index b78d75c621..8865481ade 100644 --- a/cgi-bin/webnotes/utils/backups.py +++ b/cgi-bin/webnotes/utils/backups.py @@ -128,7 +128,7 @@ def get_backup(): delete_temp_backups() webnotes.msgprint("""A download link to your backup will be emailed \ to you shortly on the following email address: - %s""" % (str(recipient_list),)) + %s""" % (', '.join(recipient_list))) def delete_temp_backups():