Skip to content

Commit 88ce32c

Browse files
committed
Merge pull request #138 from github/only-link-dist-popd-dirs
Only use --link-dest when backing up populated directories
2 parents da295de + 99a0ab7 commit 88ce32c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

share/github-backup-utils/ghe-backup-userdata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ ghe_remote_version_required "$host"
2626
# to an older version of GHE or no data has been added to this directory yet.
2727
ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0
2828

29-
# If we have a previous increment, avoid transferring existing files via rsync's
29+
# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's
3030
# --link-dest support. This also decreases physical space usage considerably.
31-
if [ -d "$GHE_DATA_DIR/current/$dirname" ]; then
31+
if [ -d "$GHE_DATA_DIR/current/$dirname" ] && [ "$(ls -A $GHE_DATA_DIR/current/$dirname)" ]; then
3232
link_dest="--link-dest=../../current/$dirname"
3333
fi
3434

test/test-ghe-backup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,16 @@ begin_test "ghe-backup without manage-password file"
251251
[ ! -f "$GHE_DATA_DIR/current/manage-password" ]
252252
)
253253
end_test
254+
255+
begin_test "ghe-backup empty hookshot directory"
256+
(
257+
set -e
258+
259+
rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-*
260+
rm -rf $GHE_DATA_DIR/current/hookshot/repository-*
261+
ghe-backup
262+
263+
# Check that the "--link-dest arg does not exist" message hasn't occurred.
264+
[ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ]
265+
)
266+
end_test

0 commit comments

Comments
 (0)