Skip to content

Move backups to block storage instead of copy#3060

Merged
mikerkelly merged 1 commit into
mainfrom
mikerkelly/backups/block-storage-move-not-copy
May 13, 2026
Merged

Move backups to block storage instead of copy#3060
mikerkelly merged 1 commit into
mainfrom
mikerkelly/backups/block-storage-move-not-copy

Conversation

@mikerkelly
Copy link
Copy Markdown
Contributor

@mikerkelly mikerkelly commented May 13, 2026

Part fixes #2910.

Database backups use significant space on the main volume of dokku3. To save space on the main drive, and to improve our storage capacity, we want to move the backups storage to DigitalOcean Block Storage.

Now that we have seen the backups successfully copy across, we can change the cp command to a mv, as the backups don't need to exist in both places. This will free up space.

I think it makes sense that the backup generation, sanitisation, and compression will continue to be done locally as the local file system access is likely faster than doing everything directly in block storage.

Cleaning up the existing backup folder can be done manually to free the space once we see that this has worked.

Tested locally with:

DATABASE_DIR=. BLOCK_STORAGE_DIR=tmp_block SKIP_SENTRY=true ./deploy/bin/backup.sh

Then checking expected files and symlinks were in place in the "block storage" location and not in the "database storage" location.

Copy link
Copy Markdown
Contributor

@StevenMaude StevenMaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summary: I have one question about maybe making the backup more robust. Otherwise, the changes look fine.

Comment thread deploy/bin/backup.sh Outdated
cp --preserve=mode,timestamps "$BACKUP_FILEPATH.zst" "$BLOCK_BACKUP_DIR"
cp --preserve=mode,timestamps "$SANITISED_BACKUP_FILEPATH.zst" "$BLOCK_BACKUP_DIR"
mv "$BACKUP_FILEPATH.zst" "$BLOCK_BACKUP_DIR"
mv "$SANITISED_BACKUP_FILEPATH.zst" "$BLOCK_BACKUP_DIR"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Since I think this involves a different filesystem, the mv is presumably a full copy operation, if I'm right?

If so, is it worthwhile to verify, either using rsync or hashing the files before and after, that the files have correctly copied, as a guard against faulty hardware?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point rsync -av --remove-source-files ?

Database backups use significant space on the main volume of dokku3. To save
space on the main drive, and to improve our storage capacity, we want to move
the backups storage to DigitalOcean Block Storage.

Now that we have seen the backups successfully copy across in production, we
can remove the source files don't need to exist in both places. This will free
up space.

`rsync` takes checksums after the transfer before deleting the local copy and
will return non-zero in the event of failure, notifying us via Sentry.

I think it makes sense that the backup generation, sanitisation, and
compression will continue to be done locally as the local file system access is
likely faster than doing everything directly in block storage.

Cleaning up the existing backup folder can be done manually to free the space
once we see that this has worked.
@mikerkelly mikerkelly force-pushed the mikerkelly/backups/block-storage-move-not-copy branch from a3547f0 to 5992212 Compare May 13, 2026 15:40
@mikerkelly mikerkelly merged commit 71a0957 into main May 13, 2026
6 checks passed
@mikerkelly mikerkelly deleted the mikerkelly/backups/block-storage-move-not-copy branch May 13, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use block storage for database backups

2 participants