Minituff / nautical-backup

A simple Docker volume backup tool.
https://minituff.github.io/nautical-backup/
GNU General Public License v3.0
196 stars 2 forks source link

USE_DEST_DATE_FOLDER breaks dest folder logic in multiple cases #237

Open FrozenDragoon opened 1 month ago

FrozenDragoon commented 1 month ago

nautical-backup.override-destination-dir Label

gitea-db-1 labels:

    labels:
      - nautical-backup.enable=true
      # This is necessary to ensure that this is all
      # backed up under the correct "gitea" subfolder
      - "nautical-backup.override-source-dir=gitea/db_data"
      - "nautical-backup.override-destination-dir=db_data"
      - nautical-backup.group=gitea

With USE_DEST_DATE_FOLDER=true

Debug output:

2024-05-17 11:19:14.594124 - INFO: Backing up group: gitea
2024-05-17 11:19:14.599246 - INFO: Stopping gitea-db-1...
2024-05-17 11:19:14.896226 - INFO: Starting API on port 8069...
2024-05-17 11:19:15.238090 - INFO: Stopping gitea-web-1...
2024-05-17 11:19:16.849318 - INFO: Overriding destination directory for gitea-db-1 to 'db_data' from label
2024-05-17 11:19:16.852670 - INFO: Backing up gitea-db-1...
2024-05-17 11:19:16.853507 - DEBUG: RUNNING: 'rsync -raq /app/source/gitea/db_data/ /app/destination/2024-05-17/gitea-db-1/'
2024-05-17 11:19:17.177266 - INFO: Backing up gitea-web-1...
2024-05-17 11:19:17.178288 - DEBUG: RUNNING: 'rsync -raq --exclude db_data/* /app/source/gitea/ /app/destination/2024-05-17/gitea-web-1/'
2024-05-17 11:19:39.037623 - INFO: Starting gitea-db-1...
2024-05-17 11:19:40.120128 - INFO: Backup of gitea-db-1 complete!
2024-05-17 11:19:40.124260 - INFO: Starting gitea-web-1...
2024-05-17 11:19:41.376388 - INFO: Backup of gitea-web-1 complete!
2024-05-17 11:19:41.379706 - DEBUG: Containers completed: gitea-db-1, gitea-web-1

With USE_DEST_DATE_FOLDER=false:

Debug output:

2024-05-17 11:21:47.051453 - INFO: Backing up group: gitea
2024-05-17 11:21:47.056162 - INFO: Stopping gitea-db-1...
2024-05-17 11:21:47.276518 - INFO: Starting API on port 8069...
2024-05-17 11:21:47.695551 - INFO: Stopping gitea-web-1...
2024-05-17 11:21:49.255066 - INFO: Overriding destination directory for gitea-db-1 to 'db_data' from label
2024-05-17 11:21:49.256711 - DEBUG: Destination directory '/app/destination/db_data' does not exit
2024-05-17 11:21:49.257826 - INFO: Backing up gitea-db-1...
2024-05-17 11:21:49.258709 - DEBUG: RUNNING: 'rsync -raq /app/source/gitea/db_data/ /app/destination/db_data/'
2024-05-17 11:21:49.453880 - DEBUG: Destination directory '/app/destination/gitea' does not exit
2024-05-17 11:21:49.455453 - INFO: Backing up gitea-web-1...
2024-05-17 11:21:49.456735 - DEBUG: RUNNING: 'rsync -raq --exclude db_data/* /app/source/gitea/ /app/destination/gitea/'

nautical-backup.additional-folders Label

Additional folders are stored outside of the date folder:

$ ls -lah /storage/nauticalbackup/
total 28K
drwxrwxr-x  4 server server 4.0K May 17 11:35  .
drwxr-xr-x 33 root   root   4.0K May 17 07:54  ..
drwxr-xr-x  4 root   root   4.0K May 17 11:34  2024-05-17
-rw-r--r--  1 root   root    12K May 17 11:35 'Backup Report - 2024-05-17.txt'
drwxr-xr-x  2 root   root   4.0K May 17 11:29  test

Debug output:

2024-05-17 11:34:57.461172 - INFO: Backing up group: gitea
2024-05-17 11:34:57.464748 - INFO: Stopping gitea-db-1...
2024-05-17 11:34:57.766336 - INFO: Starting API on port 8069...
2024-05-17 11:34:58.126005 - INFO: Stopping gitea-web-1...
2024-05-17 11:34:59.700702 - INFO: Overriding destination directory for gitea-db-1 to 'db_data' from label
2024-05-17 11:34:59.702953 - INFO: Backing up gitea-db-1...
2024-05-17 11:34:59.703785 - DEBUG: RUNNING: 'rsync -raq --dry-run /app/source/gitea/db_data/ /app/destination/2024-05-17/gitea-db-1/'
2024-05-17 11:34:59.863610 - INFO: Backing up gitea-web-1...
2024-05-17 11:34:59.864604 - DEBUG: RUNNING: 'rsync -raq --exclude db_data/* /app/source/gitea/ /app/destination/2024-05-17/gitea-web-1/'
2024-05-17 11:35:22.677432 - INFO: Backing up additional folder 'test' for container gitea-web-1
2024-05-17 11:35:22.678093 - DEBUG: RUNNING: 'rsync -raq --exclude db_data/* /app/source/test/ /app/destination/test/'
2024-05-17 11:35:22.725467 - INFO: Starting gitea-db-1...
2024-05-17 11:35:23.864727 - INFO: Backup of gitea-db-1 complete!
2024-05-17 11:35:23.869612 - INFO: Starting gitea-web-1...
2024-05-17 11:35:25.029668 - INFO: Backup of gitea-web-1 complete!
2024-05-17 11:35:25.031853 - DEBUG: Containers completed: gitea-web-1, gitea-db-1
FrozenDragoon commented 1 month ago

Ideally (for me) it'd be possible to use the overridden folder within the date folder.

Not super experienced with the Dev Container addon in VSCode, but I wonder if the issue lies here (for the nautical-backup.override-destination-dir label):

https://github.com/Minituff/nautical-backup/blob/f6061c6fadc949302ac22dc5aa499b9947db5e3e/app/backup.py#L360-L372

It looks like dst_dir is set in lines 360-363 (from the label) then set again/overwritten in the if starting on like 365 (specifically 370/372).

I wonder if you could do it some way like.... concatenating the dest_dir instead of overriding it in each if block. Maybe I can give it a shot this weekend.