Compare commits

..

No commits in common. "a406cfe849660543a7b0ceddbab2f53c6a16daf5" and "e972c90fe596e38cd2da8fa2e8c2fe0a2a9303af" have entirely different histories.

4 changed files with 20 additions and 47 deletions

View file

@ -61,7 +61,7 @@ print_help () {
}
print_and_log () {
/usr/bin/env ts "%Y-%m-%dT%H:%M:%S" | /usr/bin/tee -a $BACKUP_LOG
/usr/bin/ts "%Y-%m-%dT%H:%M:%S" | /usr/bin/tee -a $BACKUP_LOG
}
set -o errexit
@ -70,7 +70,6 @@ set -o pipefail
ACTION=$1
DESTINATION=$2
INPUT="${@:3}"
RESTIC=$(which restic)
if [[ -z $DESTINATION && $ACTION == "help" ]]; then
print_logo
@ -106,7 +105,7 @@ else
"backup")
if [[ $AC_POWER == 1 ]]; then
echo "backing up to $DESTINATION." | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--cleanup-cache \
@ -121,7 +120,7 @@ else
;;
"check")
echo "Checking backup repository at $DESTINATION" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -129,7 +128,7 @@ else
;;
"find")
echo "Searching for $INPUT at $DESTINATION"
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -141,7 +140,7 @@ else
;;
"init")
echo "Initializing backup repository at $DESTINATION" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -149,7 +148,7 @@ else
;;
"mount")
echo "Mounting backup repository $DESTINATION at $INPUT" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -157,7 +156,7 @@ else
;;
"restore")
echo "Restoring from $DESTINATION, $INPUT" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -165,7 +164,7 @@ else
;;
"snapshots")
echo "Listing snapshots on $DESTINATION"
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -173,7 +172,7 @@ else
;;
"stats")
echo "Printing statistics for $DESTINATION"
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -181,27 +180,23 @@ else
;;
"prune")
if [[ $AC_POWER == 1 ]]; then
hourly=6
daily=7
monthly=12
yearly=5
echo """
Pruning backups at $DESTINATION ...
Keeping:
- $hourly hourly backups
- $daily daily backups
- $monthly monthly backups
- $yearly yearly backups
- 24 hourly backups
- 90 daily backups
- 12 monthly backups
- 5 yearly backups
""" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
--prune \
--keep-hourly=$hourly \
--keep-daily=$daily \
--keep-monthly=$monthly \
--keep-yearly=$yearly \
--keep-hourly=24 \
--keep-daily=90 \
--keep-monthly=12 \
--keep-yearly=5 \
forget | print_and_log
else
echo "Not plugged in, canceling prune."
@ -209,7 +204,7 @@ else
;;
"unlock")
echo "Unlocking backup repository at $DESTINATION" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -217,7 +212,7 @@ else
;;
"clean")
echo "Cleaning repository at $DESTINATION" | print_and_log
RESTIC \
/usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.andrew.backup.sh</string>
<key>ProgramArguments</key>
<array>
<string>touch</string>
<string>/tmp/helloworld</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>/var/log/testDaemon.log</string>
<key>StandardErrorPath</key>
<string>/var/log/testDaemon.log</string>
</dict>
</plist>