backups fix

This commit is contained in:
Rushabh Mehta 2011-07-27 13:40:29 +05:30
parent 541c42b4fa
commit f157510541
2 changed files with 22 additions and 4 deletions

View file

@ -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'

View file

@ -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()