mirror of
https://github.com/Matir/skel.git
synced 2026-05-26 13:35:42 -07:00
Add backup script.
This commit is contained in:
29
bin/backup.sh
Executable file
29
bin/backup.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
DEFAULT=`echo /media/${USER}/[bB]ackup/${USER}/`
|
||||||
|
DEST="${1:-${DEFAULT}}"
|
||||||
|
|
||||||
|
function verify_dest {
|
||||||
|
arr=($1)
|
||||||
|
items=${#arr[@]}
|
||||||
|
if [ $items -ne 1 ] ; then
|
||||||
|
echo "Bad count of backup destinations." > /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
dir="$1"
|
||||||
|
end=$((${#dir}-1))
|
||||||
|
last="${dir:$end:1}"
|
||||||
|
if [ "$last" != "/" ] ; then
|
||||||
|
echo -n "Destination $dir does not end in a /, " > /dev/stderr
|
||||||
|
echo "this is probably not what you want!" > /dev/stderr
|
||||||
|
echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr
|
||||||
|
read
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_dest "$DEST"
|
||||||
|
|
||||||
|
rsync -Hax --delete-before --exclude-from="$HOME/.rsync_ignore" "${HOME}/" "$DEST"
|
||||||
7
dotfiles/rsync_ignore
Normal file
7
dotfiles/rsync_ignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
tmp
|
||||||
|
Downloads
|
||||||
|
.cache
|
||||||
|
.local/share/Trash
|
||||||
|
.wine
|
||||||
|
.thumbnails
|
||||||
|
.histfile
|
||||||
Reference in New Issue
Block a user