def make_test_directories(self, num_dirs=17): self.log_message('Make %s test directories' % num_dirs, header=True) if not self.BACKUP_DIR: self.fail_with_message('The attribute POORMANS_DB_BACKUP_DIR must be defined in the settings file') return for x in range(1, num_dirs+1): earlier_day = self.CURRENT_DATETIME + timedelta(days=-x) new_dirname = BackupMaker.get_backup_subdirectory_name(earlier_day) full_new_dirname = os.path.join(self.BACKUP_DIR, new_dirname) if os.path.isdir(full_new_dirname): self.log_message('(%s) dir exists: %s' % (x, full_new_dirname)) continue os.makedirs(full_new_dirname) self.log_message('(%s) new dir made: %s' % (x, full_new_dirname)) test_filename = os.path.join(full_new_dirname, 'afile.txt') fh = open(test_filename, 'w') fh.write('blah') fh.close() self.log_message('test file: %s' % (test_filename))
import os, sys sys.path.append('/home/p/r/prasad/webapps/django/MCB-Graphics-Printer-Scheduler/mcb_printer_scheduler') sys.path.append('/home/p/r/prasad/webapps/django/MCB-Graphics-Printer-Scheduler') from mcb_printer_scheduler import settings from django.core.management import setup_environ setup_environ(settings) # pull in "BackupMaker" sys.path.append('/home/p/r/prasad/webapps/django/mcb_lib/poor-mans-db-backup') from backupdb.backup_files import BackupMaker if __name__ == '__main__': mb = BackupMaker(backup_name='Poster Printer') mb.make_backup()
import os, sys sys.path.append('/var/webapps/django/mcb-finance-utilities/') sys.path.append('/var/webapps/django/mcb-finance-utilities/finance_utilities') from finance_utilities import settings from django.core.management import setup_environ setup_environ(settings) # pull in "BackupMaker" sys.path.append('/var/webapps/django/mcb_lib/poor-mans-db-backup') from backupdb.backup_files import BackupMaker if __name__ == '__main__': mb = BackupMaker(backup_name='Finance Utilities (hcom training)') mb.make_backup()