Percona-Lab / mongodb_consistent_backup

A tool for performing consistent backups of MongoDB Clusters or Replica Sets
https://www.percona.com
Apache License 2.0
276 stars 81 forks source link

Encryption for zbackup failed when there is existing encrypted zbackup folder #274

Open radityapujamurti opened 5 years ago

radityapujamurti commented 5 years ago

Hi,

Below is the part of config file used for zbackup encryption:

...
archive: 
    method: zbackup
    zbackup:
      password_file: /path/to/password

The first run was successful with no error. However, the next run failed with the following log:

... [2018-08-17 05:00:03,066] [INFO] [MainProcess] [State:load_backups:162] Found 3 existing completed backups for set [2018-08-17 05:00:03,067] [INFO] [MainProcess] [State:init:131] Initializing backup state directory: /path/to/backup/20180817_0500 [2018-08-17 05:00:03,082] [INFO] [MainProcess] [Zbackup:init:52] Found existing ZBackup storage dir at: /path/to/backup/mongodb-consistent-backup_zbackup (encrypted: False) ... [2018-08-17 05:14:17,419] [INFO] [MainProcess] [Resolver:run:142] Oplog resolving completed in 0.00 seconds [2018-08-17 05:14:17,423] [INFO] [MainProcess] [Stage:run:83] Running stage mongodb_consistent_backup.Archive with task: Zbackup [2018-08-17 05:14:17,806] [INFO] [MainProcess] [Zbackup:run:164] Starting ZBackup version: 1.4.3 (options: compression=lzma, encryption=False, threads=32, cache_mb=128) [2018-08-17 05:14:17,806] [INFO] [MainProcess] [Zbackup:run:171] Running ZBackup for path: /path/to/backup/20180817_0500/test1 [2018-08-17 05:14:17,856] [INFO] [MainProcess] [Zbackup:poll:125] Invalid password specified [2018-08-17 05:14:17,860] [ERROR] [MainProcess] [Stage:run:99] Stage mongodb_consistent_backup.Archive did not complete! [2018-08-17 05:14:17,861] [CRITICAL] [MainProcess] [Main:exception:207] Problem performing archiving! Error: Stage mongodb_consistent_backup.Archive did not complete! ...

I suspect the error is caused by the following part:

[mongodb_consistent_backup/mongodb_consistent_backup/Archive/Zbackup/Zbackup.py]

...
if os.path.isdir(self.zbackup_dir):
    if self.is_zbackup_init():
        logging.info("Found existing ZBackup storage dir at: %s (encrypted: %s)" % (self.zbackup_dir, self.encrypted))
    else:
        raise OperationError("ZBackup dir: %s is not a zbackup storage directory!" % self.zbackup_dir)
else:
...

There should be a check on whether password_file parameter is defined in the config file at if self.is_zbackup_init(): to determine self.encrypted

Thank you.