Initial commit
This commit is contained in:
38
backup.sh
Executable file
38
backup.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
BASEDIR="$(dirname ${0} | sed "s|^.|${PWD}|")"
|
||||
source "${BASEDIR}/backup.conf"
|
||||
TIMESTAMP="$(date +%Y_%m_%d-%H_%M_%S)"
|
||||
SNAPSHOT="${SOURCE}@${TIMESTAMP}"
|
||||
|
||||
|
||||
sudo zfs snapshot ${SNAPSHOT}
|
||||
|
||||
if [[ -f "${BASEDIR}/backup-last" ]]; then
|
||||
BACKUP_LAST="$(cat ${BASEDIR}/backup-last)"
|
||||
|
||||
sudo \
|
||||
zfs \
|
||||
send \
|
||||
-i ${BACKUP_LAST} \
|
||||
${SNAPSHOT} \
|
||||
| \
|
||||
sudo \
|
||||
zfs \
|
||||
receive \
|
||||
${DEST}
|
||||
else
|
||||
sudo \
|
||||
zfs \
|
||||
send \
|
||||
${SNAPSHOT} \
|
||||
| \
|
||||
sudo \
|
||||
zfs \
|
||||
receive \
|
||||
${DEST}
|
||||
fi
|
||||
|
||||
printf "@${TIMESTAMP}" | tee "${BASEDIR}/backup-last" &> /dev/null
|
Reference in New Issue
Block a user