nk20-scripts/shell/backup_db

15 lines
308 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
2024-08-10 17:03:29 +00:00
export $(cat .env_borg | xargs)
2020-09-08 11:16:03 +00:00
# Create temporary backups directory
mkdir -p /tmp/note-backups
2024-08-10 17:03:29 +00:00
# Backup database
sudo -u postgres pg_dump -F t note_db > $BACKUP_FILE
# Keep the last 30 backups
borg prune --keep-last 30
# Save backup
borg create --compression lz4 ::backup-{now} $BACKUP_FILE