Skip to content

Commit b60a3e6

Browse files
committed
doc update and prune timing
1 parent 6357cf4 commit b60a3e6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

docs/scheduling-backups.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Scheduling backups
1+
# Scheduling backups & snapshot pruning
22

33
Regular backups should be scheduled using `cron(8)` or similar command
44
scheduling service on the backup host. The backup frequency will dictate the
@@ -17,6 +17,13 @@ based on the frequency of backups. The ten most recent snapshots are retained by
1717
default. The number should be adjusted based on backup frequency and available
1818
storage.
1919

20+
By default all expired and incomplete snapshots are deleted at the end of the main
21+
backup process `ghe-backup`. If pruning of these snapshots takes a long time you can
22+
choose to disable the pruning process from the backup run and schedule it separately.
23+
This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`.
24+
Please note if this option is enabled, you will need to schedule the pruning script `ghe-prune-snapshots`
25+
using `cron` or similar command scheduling service on the backup host.
26+
2027
To schedule hourly backup snapshots with verbose informational output written to
2128
a log file and errors generating an email:
2229

@@ -30,5 +37,10 @@ To schedule nightly backup snapshots instead, use:
3037

3138
0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1
3239

40+
To schedule daily snapshot pruning, use:
41+
42+
43+
44+
0 3 * * * /opt/backup-utils/share/github-backup-utils/ghe-prune-snapshots 1>>/opt/backup-utils/prune-snapshots.log 2>&1
3345

3446
[1]: https://en.wikipedia.org/wiki/Recovery_point_objective

share/github-backup-utils/ghe-prune-snapshots

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ prune_snapshot() {
2424
#if [ ! -f "$GHE_DATA_DIR/in-progress" ] && [ ! -f "$GHE_DATA_DIR/in-progress-restore" ]; then
2525
# Check for backup or restore in-progress file
2626
inprogress_file=$(find $GHE_DATA_DIR -maxdepth 1 -type f \( -name "in-progress" -o -name "in-progress-restore" \) -print -quit)
27-
if [ -z "$inprogress_file" ]; then
27+
if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then
2828
# First prune all incomplete / failed snapshot directories
2929
prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)"
3030
prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l)
@@ -43,7 +43,7 @@ if [ -z "$inprogress_file" ]; then
4343
log_info Pruning $prune_num "expired snapshot(s) ..."
4444
echo "$prune_dirs" | prune_snapshot
4545
fi
46-
else
46+
elif [ "$CALLING_SCRIPT" != "ghe-backup" ] && [ -n "$inprogress_file" ]; then
4747
log_info "Detected a running backup/restore process, please wait until that process is complete to prune expired/incomplete snapshots." 1>&2
4848
log_info "If no such process is running, please remove the "$GHE_DATA_DIR/in-progress*" file and retry again." 1>&2
4949
fi

0 commit comments

Comments
 (0)