23 lines
597 B
Bash
Executable File
23 lines
597 B
Bash
Executable File
#!/bin/sh
|
|
. $HOME/.bin/_config
|
|
|
|
_target=$(readlink -f "$1" 2> /dev/null)
|
|
|
|
[ ! "$_target" ] \
|
|
&& printf "Usage: backup <target>\n" \
|
|
&& exit 2;
|
|
|
|
print "pass Internet/Tarsnap.key > /root/tarsnap.key ..."
|
|
pass Internet/Tarsnap.key | doas tee /root/tarsnap.key > /dev/null
|
|
doas chown root:sdk /root/tarsnap.key
|
|
doas chmod 640 /root/tarsnap.key
|
|
doas chmod 750 /root
|
|
|
|
print "Tarsnap Backup:"
|
|
|
|
_key=$(pwgen -n1 8)
|
|
_date=$(date "+%Y-%m-%d %H:%M")
|
|
_host=$(uname -n)
|
|
|
|
doas tarsnap --humanize-numbers --checkpoint-bytes 52428800 --exclude "*/.git/*" -cvf "$_host: $_target $_date ($_key)" "$_target"
|