Example #1
0
 def _zero_backup_dir(self, backup):
     """
     :param backup:
     :type backup: freezer.storage.Backup
     :return:
     """
     backup_dir = utils.joined_path(
         self.storage_directory, backup.hostname_backup_name)
     return utils.joined_path(backup_dir, backup.full_backup.timestamp)
Example #2
0
 def get_backups(self):
     backup_names = self.ftp.listdir(self.storage_directory)
     backups = []
     for backup_name in backup_names:
         backup_dir = utils.joined_path(self.storage_directory, backup_name)
         timestamps = self.ftp.listdir(backup_dir)
         for timestamp in timestamps:
             increments = self.ftp.listdir(
                 utils.joined_path(backup_dir, timestamp))
             backups.extend(storage.Backup.parse_backups(increments))
     return backups
Example #3
0
 def download_meta_file(self, backup):
     """
     :type backup: freezer.storage.Backup
     :param backup:
     :return:
     """
     utils.create_dir(self.work_dir)
     if backup.level == 0:
         return utils.joined_path(self.work_dir, backup.tar())
     meta_backup = backup.full_backup.increments[backup.level - 1]
     zero_backup = self._zero_backup_dir(backup)
     to_path = utils.joined_path(self.work_dir, meta_backup.tar())
     if os.path.exists(to_path):
         os.remove(to_path)
     from_path = utils.joined_path(zero_backup, meta_backup.tar())
     shutil.copyfile(from_path, to_path)
     return to_path
Example #4
0
 def backup_to_file_path(self, backup):
     return utils.joined_path(self._zero_backup_dir(backup),
                              backup)
Example #5
0
 def upload_meta_file(self, backup, meta_file):
     zero_backup = self._zero_backup_dir(backup)
     to_path = utils.joined_path(zero_backup, backup.tar())
     shutil.copyfile(meta_file, to_path)