Skip to content

Commit 0114a77

Browse files
authored
Merge pull request #1749 from bdunne/scheduled_backups
Add documentation for scheduling database backups using crontab
2 parents 8d6db24 + 93d761b commit 0114a77

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

appliances/backup_and_restore.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ Creating a backup of the appliance will be done using SSH or the console.
1515

1616
3. Save and/or rename `/root/backup.tgz`
1717

18+
# Scheduling Database Backups
19+
Scheduling a database backup using crontab and pg_dump.
20+
This example will create a backup file in `/tmp` named something like `db_dump20231009T145028.dump`.
21+
Before adding the cron job it would be best practice to mount an external storage and adjust the example accordingly.
22+
23+
1. SSH into the appliance and edit the root user crontab `crontab -e`
24+
2. Press `i` to insert and add a line with the desired schedule to run the backup job. Examples:
25+
```bash
26+
# Every hour on the hour
27+
0 * * * * pg_dump -Fc vmdb_production > /tmp/db_dump$(date +\%Y\%m\%dT\%H\%M\%S).dump
28+
# Every day at midnight
29+
0 0 * * * pg_dump -Fc vmdb_production > /tmp/db_dump$(date +\%Y\%m\%dT\%H\%M\%S).dump
30+
# Every week at midnight on Sunday
31+
0 0 * * 0 pg_dump -Fc vmdb_production > /tmp/db_dump$(date +\%Y\%m\%dT\%H\%M\%S).dump
32+
```
33+
3. Press `Esc` to exit insert mode then `:wq` and hit `Enter` to write and quit. If successful, it will output `crontab: installing new crontab`
34+
4. Done. If needed, logs can be found at `/var/log/cron`
35+
1836
# Restore
1937
Restoring a backup of the appliance will be done using SSH or the console.
2038

0 commit comments

Comments
 (0)