Skip to content

Commit e101998

Browse files
committed
Switch all relevant GHE_REMOTE_DATA_DIR to GHE_REMOTE_DATA_USER_DIR
Anything that needs the path to a persistent storage location now uses GHE_REMOTE_DATA_USER_DIR instead of GHE_REMOTE_DATA_DIR.
1 parent b1c88f5 commit e101998

13 files changed

Lines changed: 48 additions & 46 deletions

libexec/ghe-backup-es-rsync

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ fi
2323
mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch"
2424

2525
# Verify that the /data/elasticsearch directory exists.
26-
if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_DIR/elasticsearch' ]"; then
27-
echo "* The /data/elasticsearch directory doesn't exist." 1>&3
26+
if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then
27+
echo "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." 1>&3
2828
exit 0
2929
fi
3030

@@ -34,7 +34,7 @@ fi
3434
# XXX This should be fixed on the appliance side but will need to be maintained
3535
# for versions up to at least 11.10.343.
3636
echo "* Retrieving elasticsearch.yml config file ..." 1>&3
37-
ghe-ssh "$host" -- "sudo grep -F '' '$GHE_REMOTE_DATA_DIR/elasticsearch/elasticsearch.yml'" \
37+
ghe-ssh "$host" -- "sudo grep -F '' '$GHE_REMOTE_DATA_USER_DIR/elasticsearch/elasticsearch.yml'" \
3838
> "$GHE_SNAPSHOT_DIR/elasticsearch/elasticsearch.yml"
3939
chmod 0600 "$GHE_SNAPSHOT_DIR/elasticsearch/elasticsearch.yml"
4040

@@ -53,7 +53,7 @@ ghe-rsync -avz \
5353
--rsync-path='sudo -u git rsync' \
5454
$link_dest \
5555
--exclude='elasticsearch.yml' \
56-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/elasticsearch/" \
56+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \
5757
"$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3
5858

5959
# Set up a trap to re-enable flushing on exit
@@ -78,5 +78,5 @@ ghe-rsync -avz \
7878
--rsync-path='sudo -u git rsync' \
7979
$link_dest \
8080
--exclude='elasticsearch.yml' \
81-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/elasticsearch/" \
81+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \
8282
"$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3

libexec/ghe-backup-es-tarball

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd $(dirname "$0")/..
1313
# Snapshot all Elasticsearch data or fake it when no /data/elasticsearch
1414
# directory exists.
1515
echo "
16-
if [ -d '$GHE_REMOTE_DATA_DIR/elasticsearch' ]; then
16+
if [ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]; then
1717
ghe-export-es-indices
1818
else
1919
tar cvf - --files-from /dev/null

libexec/ghe-backup-pages-rsync

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ host="$GHE_HOSTNAME"
2121

2222
# Verify that the /data/pages directory exists. It won't if no pages sites have
2323
# been published under some versions.
24-
ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_DIR/pages' ]" || exit 0
24+
ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/pages' ]" || exit 0
2525

2626
# If we have a previous increment, avoid transferring existing files via rsync's
2727
# --link-dest support. This also decreases physical space usage considerably.
@@ -36,5 +36,5 @@ ghe-rsync -avz \
3636
-e "ghe-ssh -p $(ssh_port_part "$host")" \
3737
--rsync-path='sudo -u git rsync' \
3838
$link_dest \
39-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/pages/" \
39+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/pages/" \
4040
"$GHE_SNAPSHOT_DIR/pages" 1>&3

libexec/ghe-backup-redis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ ghe-ssh "$GHE_HOSTNAME" /bin/sh <<EOF
2020
while [ \$(redis-cli LASTSAVE) -eq \$timestamp ]; do
2121
sleep 1
2222
done
23-
cat '$GHE_REMOTE_DATA_DIR/redis/dump.rdb'
23+
cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb'
2424
EOF

libexec/ghe-backup-repositories-rsync

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ backup_current="$GHE_DATA_DIR/current/repositories"
4444

4545
# Remote sync-in-progress file location. When this file exists, Git GC
4646
# operations are disabled on the GitHub instance.
47-
sync_in_progress_file="$GHE_REMOTE_DATA_DIR/repositories/.sync_in_progress"
47+
sync_in_progress_file="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"
4848

4949
# Verify rsync is available.
5050
if ! rsync --version 1>/dev/null 2>&1; then
@@ -97,7 +97,7 @@ rsync_repository_data () {
9797
$link_dest "$@" \
9898
--rsync-path='sudo -u git rsync' \
9999
--include-from=- --exclude=\* \
100-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/repositories/" \
100+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/repositories/" \
101101
"$backup_dir" 1>&3
102102
}
103103

libexec/ghe-restore-es-rsync

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ fi
3333

3434
if [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
3535
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/elasticsearch"
36-
ghe-ssh "$host" -- "sudo mkdir -p $GHE_REMOTE_DATA_DIR/elasticsearch-legacy" 1>&3
36+
ghe-ssh "$host" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3
3737

3838
$TAR -cf - --owner=root --group=root . |
39-
ghe-ssh "$host" -- "sudo tar -xf - -C $GHE_REMOTE_DATA_DIR/elasticsearch-legacy" 1>&3
39+
ghe-ssh "$host" -- "sudo tar -xf - -C '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3
4040
else
4141
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
4242
$TAR -cf - --owner=root --group=root elasticsearch |

libexec/ghe-restore-pages-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/" ]; then
2727
-e "ghe-ssh -p $(ssh_port_part "$host")" \
2828
--rsync-path="sudo -u git rsync" \
2929
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/" \
30-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/pages" 1>&3
30+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/pages" 1>&3
3131
fi

libexec/ghe-restore-repositories-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ ghe-rsync -av --delete \
2626
-e "ghe-ssh -p $(ssh_port_part "$host")" \
2727
--rsync-path="sudo -u git rsync" \
2828
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \
29-
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_DIR/repositories" 1>&3
29+
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/repositories" 1>&3

test/bin/redis-cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ case "$1" in
1212
date +%s
1313
;;
1414
BGSAVE)
15-
mkdir -p "$GHE_REMOTE_DATA_DIR/redis"
16-
echo "fake redis data" > "$GHE_REMOTE_DATA_DIR/redis/dump.rdb"
15+
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/redis"
16+
echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb"
1717
;;
1818
*)
1919
echo "unexpected redis-cli command: $1" 1>&2

test/test-ghe-backup-repositories-rsync.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
. $(dirname "$0")/testlib.sh
66

77
# Create the backup data dir and fake remote repositories dirs
8-
mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_DIR/repositories"
8+
mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR/repositories"
99
mkdir -p "$TRASHDIR/hooks"
1010

1111
# Create some test repositories in the remote repositories dir
12-
cd "$GHE_REMOTE_DATA_DIR/repositories"
12+
cd "$GHE_REMOTE_DATA_USER_DIR/repositories"
1313
mkdir alice bob
1414
mkdir alice/repo1.git alice/repo2.git bob/repo3.git
1515

@@ -57,7 +57,7 @@ begin_test "ghe-backup-repositories-rsync first snapshot"
5757
[ -f "$GHE_DATA_DIR"/1/repositories/bob/repo3.git/svn_data/property_history.msgpack ]
5858

5959
# verify all repository data was transferred
60-
diff -ru "$GHE_REMOTE_DATA_DIR/repositories" "$GHE_DATA_DIR/1/repositories"
60+
diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/1/repositories"
6161
)
6262
end_test
6363

@@ -86,7 +86,7 @@ begin_test "ghe-backup-repositories-rsync subsequent snapshot"
8686
[ "$inode1" = "$inode2" ]
8787

8888
# verify all repository data exists in the increment
89-
diff -ru "$GHE_REMOTE_DATA_DIR/repositories" "$GHE_DATA_DIR/2/repositories"
89+
diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/2/repositories"
9090
)
9191
end_test
9292

@@ -100,13 +100,13 @@ begin_test "ghe-backup-repositories-rsync __special__ dirs"
100100
export GHE_SNAPSHOT_TIMESTAMP
101101

102102
# create the excluded __nodeload_archives__ dir on the remote side
103-
mkdir "$GHE_REMOTE_DATA_DIR/repositories/__nodeload_archives__"
104-
touch "$GHE_REMOTE_DATA_DIR/repositories/__nodeload_archives__/something.tar.gz"
103+
mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories/__nodeload_archives__"
104+
touch "$GHE_REMOTE_DATA_USER_DIR/repositories/__nodeload_archives__/something.tar.gz"
105105

106106
# create the included __purgatory__ dir on the remote side
107-
mkdir -p "$GHE_REMOTE_DATA_DIR/repositories/__purgatory__/123.git"
108-
git init --bare -q "$GHE_REMOTE_DATA_DIR/repositories/__purgatory__/123.git"
109-
git --git-dir="$GHE_REMOTE_DATA_DIR/repositories/__purgatory__/123.git" --work-tree=. \
107+
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git"
108+
git init --bare -q "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git"
109+
git --git-dir="$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" --work-tree=. \
110110
commit --allow-empty -m 'test commit'
111111

112112
# run it
@@ -139,7 +139,7 @@ begin_test "ghe-backup-repositories-rsync temp files"
139139
export GHE_SNAPSHOT_TIMESTAMP
140140

141141
# create a tmp pack to emulate a pack being written to
142-
touch "$GHE_REMOTE_DATA_DIR/repositories/alice/repo1.git/objects/pack/tmp_pack_1234"
142+
touch "$GHE_REMOTE_DATA_USER_DIR/repositories/alice/repo1.git/objects/pack/tmp_pack_1234"
143143

144144
# run it
145145
ghe-backup-repositories-rsync

0 commit comments

Comments
 (0)