Skip to content

Commit 56529f9

Browse files
authored
Merge pull request #466 from github/gamefiend-fix-pruning
Fix pruning snapshots during backup.
2 parents 7c556a4 + f210a47 commit 56529f9

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

share/github-backup-utils/ghe-backup-config

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,6 @@ PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH"
191191
# backup.config value when set.
192192
GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME"
193193

194-
# Source in the backup config file from the copy specified in the environment
195-
# first and then fall back to the backup-utils root, home directory and system.
196-
config_found=false
197-
for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \
198-
"$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do
199-
if [ -f "$f" ]; then
200-
GHE_BACKUP_CONFIG="$f"
201-
# shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted
202-
. "$GHE_BACKUP_CONFIG"
203-
config_found=true
204-
break
205-
fi
206-
done
207-
208-
# If we don't have a readlink command, error out
209-
! type readlink 1>/dev/null 2>&1 && {
210-
echo "Error: readlink not found. Please install readlink and ensure it is in your PATH." 1>&2
211-
exit 1
212-
}
213-
214-
GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore")
215-
GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup")
216-
217-
export GHE_RESTORE_IN_PROGRESS
218-
export GHE_BACKUP_IN_PROGRESS
219194

220195
ghe_restore_check() {
221196
if [ -h "$GHE_RESTORE_IN_PROGRESS" ]; then

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@ prune_snapshot() {
1717
# ignore any directory that is included in inc_full_backup or inc_snapshot_data
1818
# the files should be filtered out earlier, but this is a safeguard to make sure.
1919
# inc_previous_* and prune_inc_previous are ignored by default
20-
if grep -q "$prune_dir" "$GHE_DATA_DIR/inc_full_backup" || grep "$prune_dir" "$GHE_DATA_DIR/inc_snapshot_data"; then
21-
continue
20+
if [ -f "$GHE_DATA_DIR/inc_full_backup" ]; then
21+
if grep -q "$prune_dir" "$GHE_DATA_DIR"/inc_full_backup; then
22+
log_info "Skipping incremental backup directory: $prune_dir" 1>&3
23+
continue
24+
fi
25+
fi
26+
27+
if [ -f "$GHE_DATA_DIR/inc_snapshot_data" ]; then
28+
if grep -q "$prune_dir" "$GHE_DATA_DIR"/inc_snapshot_data; then
29+
log_info "Skipping incremental backup directory: $prune_dir" 1>&3
30+
continue
31+
fi
2232
fi
33+
2334
# skip if the directory is not a directory or blank
2435
if [ ! -d "$prune_dir" ] || [ -z "$prune_dir" ]; then
2536
log_info "Skipping blank or non-directory: $prune_dir" 1>&3

0 commit comments

Comments
 (0)