-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial import from AUR version 1.0.1
- Loading branch information
1 parent
dff9ddd
commit 2da2faa
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh | ||
CONFFILE=/etc/luky-borg-backup.conf | ||
. $CONFFILE | ||
|
||
if [ -z "$REPOSITORY" ]; then | ||
echo "ERROR: No REPOSITORY set. Please edit $CONFFILE" | ||
exit | ||
fi | ||
|
||
# Try to mount the MOUNTPOINT first (if one exists) | ||
premounted="1" # assume all mounts were already in place before we started | ||
mounted="1" # assume a mounted state until proven otherwise | ||
if [ ! -z "$MOUNTPOINT" ]; then | ||
premounted="0" | ||
mounted="0" | ||
|
||
if [ `mount | grep -c "$MOUNTPOINT"` -ne "0" ]; then | ||
premounted="1" | ||
mounted="1" | ||
echo "$MOUNTPOINT was already mounted..." | ||
else | ||
echo "Mounting $MOUNTPOINT..." | ||
mount "$MOUNTPOINT" | ||
if [ "$?" -ne "0" ]; then | ||
echo "ERROR: $MOUNTPOINT could not be mounted!" | ||
else | ||
echo " Mounted $MOUNTPOINT!" | ||
mounted="1" | ||
fi | ||
fi | ||
fi | ||
|
||
if [ "$mounted" -eq "1" ]; then | ||
# Backup all necessary files and directories using deduplication and lz4 conpression | ||
|
||
echo | ||
echo "Backing up to $REPOSITORY..." | ||
borg create -v -s --noatime -C lz4 $REPOSITORY::'{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}' $SOURCES | ||
echo " Backed up to $REPOSITORY!" | ||
echo | ||
|
||
# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly | ||
# archives of THIS machine. The '{hostname}-' prefix is very important to | ||
# limit prune's operation to this machine's archives and not apply to | ||
# other machine's archives also. | ||
borg prune -v --list $REPOSITORY --prefix '{hostname}-' --keep-daily=7 --keep-weekly=4 --keep-monthly=12 | ||
|
||
if [ ! -z "$CLOUDFOLDER" ]; then | ||
echo | ||
echo "Syncing $REPOSITORY with $CLOUDFOLDER..." | ||
owncloudcmd -u $CLOUDUSER -s -p $CLOUDPASSWORD -h $REPOSITORY $CLOUDFOLDER | ||
echo " Synced $REPOSITORY with $CLOUDFOLDER!" | ||
fi | ||
|
||
if [ ! -z "$MOUNTPOINT" ]; then | ||
echo | ||
echo "==============================================" | ||
echo "Usage of filesystem at $MOUNTPOINT after backing up:" | ||
echo "----------------------------------------------" | ||
df -hT ${MOUNTPOINT} | ||
echo "==============================================" | ||
echo | ||
|
||
if [ "$premounted" -eq "0" ]; then | ||
echo "Unmounting $MOUNTPOINT..." | ||
umount "$MOUNTPOINT" | ||
if [ "$?" -eq "0" ]; then | ||
echo " Unmounted $MOUNTPOINT" | ||
else | ||
echo "ERROR: $MOUNTPOINT could not be unmountedi!" | ||
fi | ||
else | ||
echo "Keeping $MOUNTPOINT mounted because it was already mounted!" | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Optionally, set a MOUNTPOINT to mount at start and unmount at finish | ||
# (if it wasn't mounted already at start). i.e.: | ||
# MOUNTPOINT=/mnt | ||
|
||
# Optionally set the Stack (or Owncloud or Nextcloud) folder to sync backups to. i.e.: | ||
# CLOUDFOLDER="https://transip.stackstorage.com/remote.php/webdav/backup" | ||
|
||
# Optionally set a username and password for Stack (or Owncloud or Nextcloud). i.e.: | ||
# CLOUDUSER="admin" | ||
# CLOUDPASSWORD="password" | ||
|
||
# Optionally export the BORG_PASSPHRASE to be able to non-interactively create an encrypted backup (Recommended). i.e.: | ||
# export BORG_PASSPHRASE='secret' | ||
|
||
# Optionally, export other BORG Environment Variables. i.e.: | ||
# export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes # non-interactively accept relocation of a repository | ||
|
||
# Set the borg REPOSITORY to backup to. i.e.: | ||
# REPOSITORY="$MOUNTPOINT/backup" | ||
|
||
# Define the folders/files to include/exclude. i.e.: | ||
# SOURCES="\ | ||
# /etc \ | ||
# /srv/http \ | ||
# -e /etc/mtab \ | ||
# " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=LukyLX Incremental Backup | ||
Wants=unit-status-mail@%n.service | ||
Before=unit-status-mail@%n.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/luky-borg-backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Run luky-borg-backup every night | ||
|
||
[Timer] | ||
OnCalendar=04:00 | ||
AccuracySec=1h | ||
Persistent=yes | ||
|
||
[Install] | ||
WantedBy=timers.target |