Skip to content

Commit 2e3d856

Browse files
committed
Add root backup for rsync
1 parent 34171ec commit 2e3d856

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

backup/rsync.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
REPO_DIR="$(dirname "${SCRIPT_DIR}")"
6+
TIMESTAMP="$(date +%Y-%m-%d_%H-%M-%S)"
7+
LOG_PATH="${REPO_DIR}/logs/rsync_backup_${TIMESTAMP}.txt"
8+
HOSTNAME="$(hostname)"
9+
HOSTNAME_TRIMMED="${HOSTNAME%"-kubuntu"}"
10+
11+
if [ "$#" -ne 1 ]; then
12+
echo "Usage: ${0} <home|root>"
13+
exit 1
14+
elif [ "${1}" == "home" ]; then
15+
rsync \
16+
--archive --compress --delete --partial --progress --stats \
17+
--exclude-from="${SCRIPT_DIR}/rsync_exclude_home.txt" \
18+
"${HOME}" \
19+
"${USER}@agx-file-backup:/mnt/backup/${HOSTNAME_TRIMMED}/rsync/" |& tee -a "${LOG_PATH}"
20+
elif [ "${1}" == "root" ]; then
21+
rsync \
22+
--archive --delete --partial --progress --stats \
23+
--exclude-from="${SCRIPT_DIR}/rsync_exclude_root.txt" \
24+
/ \
25+
"/mnt/h12-backup-3tb/rsync/" |& tee -a "${LOG_PATH}"
26+
else
27+
echo "Usage: ${0} <home|root>"
28+
exit 1
29+
fi

backup/rsync_exclude_root.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bin
2+
dev
3+
lib
4+
lib32
5+
lib64
6+
libx32
7+
lost+found
8+
media
9+
mnt
10+
proc
11+
sbin
12+
sys
13+
tmp

backup/rsync_home.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)