This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backup scripts, Update to 0.16.0
- Loading branch information
Showing
5 changed files
with
55 additions
and
5 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.DS_Store | ||
.DS_Store | ||
.vscode |
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
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,32 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
start=$(date +%s) | ||
echo "Starting backup: ${RESTIC_BACKUP_SOURCE} to ${RESTIC_REPOSITORY} $(date +"%Y-%m-%d %H:%M:%S")" | ||
|
||
set +e | ||
restic backup ${RESTIC_BACKUP_ARGS} "${RESTIC_BACKUP_SOURCE}" | ||
backupRC=$? | ||
set -e | ||
|
||
if [[ $backupRC == 0 ]]; then | ||
echo "Backup successful" | ||
else | ||
echo "Backup failed with status: ${backupRC}" | ||
restic unlock | ||
fi | ||
|
||
if [[ $backupRC == 0 ]] && [ -n "${RESTIC_FORGET_ARGS}" ]; then | ||
echo "Forgetting old snapshots with: ${RESTIC_FORGET_ARGS}" | ||
if restic forget ${RESTIC_FORGET_ARGS}; then | ||
echo "Forget successful" | ||
else | ||
echo "Forget failed" | ||
restic unlock | ||
fi | ||
fi | ||
|
||
end=$(date +%s) | ||
echo "Finished backup at: $(date +"%Y-%m-%d %H:%M:%S") in $((end-start)) seconds." | ||
|
||
exit $backupRC |
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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
if [[ -f $INIT_SCRIPT ]]; then | ||
echo "Running init script: ${INIT_SCRIPT}" | ||
source "$INIT_SCRIPT" | ||
fi | ||
|
||
echo "Running Restic: $(date)" | ||
echo "Checking repository: ${RESTIC_REPOSITORY}" | ||
if restic cat config > /dev/null; then | ||
echo "Found repository" | ||
else | ||
echo "Initializing repository: ${RESTIC_REPOSITORY}" | ||
if restic init; then | ||
echo "Initialized repository" | ||
else | ||
echo "Failed to initialize repository" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
exec "$@" |