Initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
backup.conf
|
||||||
|
backup-last
|
2
backup.conf
Normal file
2
backup.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SOURCE=""
|
||||||
|
DEST=""
|
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