|
37 | 37 | # get the pvc metadata name using the parsed get pvc output
|
38 | 38 | pvc_name = pvc_data.get(volume_name, "")
|
39 | 39 | if pvc_name:
|
40 |
| - # create a borg archive named according to YYYY-MM-DD-pvc.metadata.name, cd-ing into the volume directory first |
| 40 | + # create a borg archive named according to pvc.metadata.name-YYYY-MM-DD, cd-ing into the volume directory first |
41 | 41 | # contents of archive will be identical to contents of the PVC at time of archive creation, to simplify backup restore
|
42 |
| - # to restore a backup to the current folder: 'borg extract ${REPOSITORY}::YYYY-MM-DD-pvc.metadata.name' |
43 |
| - # example backup command : borg create /mnt/repo::2020-02-01-sonarr . |
44 |
| - # example restory command: borg extract /mnt/repo::2020-02-01-sonarr |
| 42 | + # to restore a backup to the current folder: 'borg extract ${REPOSITORY}::pvc.metadata.name-YYYY-MM-DD' |
| 43 | + # example backup command : borg create /mnt/repo::sonarr-2020-02-01 . |
| 44 | + # example restory command: borg extract /mnt/repo::sonarr-2020-02-01 |
45 | 45 | subprocess.check_call(["borg", "create", "-v", "--stats", "--compression", "auto,zstd",
|
46 |
| - f"{REPOSITORY}::{{now:%Y-%m-%d}}-{pvc_name}", "."], |
| 46 | + f"{REPOSITORY}::{pvc_name}-{{now:%Y-%m-%d}}", "."], |
47 | 47 | cwd=volume, env={"BORG_PASSPHRASE": BORG_PASSPHRASE})
|
| 48 | + |
| 49 | + # prune borg repo, removing old backups for this pvc_name |
| 50 | + # note the --prefix, to limit pruning |
| 51 | + subprocess.check_call(["borg", "prune", "-v", "--list", REPOSITORY, "--prefix", pvc_name, |
| 52 | + "--keep-daily=7", "--keep-weekly=4", "--keep-monthly=6", "--keep-yearly=1"], |
| 53 | + env={"BORG_PASSPHRASE": BORG_PASSPHRASE}) |
0 commit comments