summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2021-11-28 15:45:27 +0100
committerMarc Vertes <mvertes@free.fr>2021-11-28 15:45:27 +0100
commitb9df08e08dc7eba9352bc68a4d1bb55c8d27529f (patch)
treed6b20cf31ae2c68aaecd125ea392ae28e564d305
parent7a36b02b5f3ae6560030c97513b8c15d9abd16d8 (diff)
update
-rw-r--r--.backupignore11
-rw-r--r--.bashrc1
-rwxr-xr-xbin/backup16
3 files changed, 21 insertions, 7 deletions
diff --git a/.backupignore b/.backupignore
new file mode 100644
index 0000000..8f44c0d
--- /dev/null
+++ b/.backupignore
@@ -0,0 +1,11 @@
+.Trash/
+*[Cc]ache*/
+.bundle/
+.*[Cc]ache*/
+.cargo/
+.cpan*
+.gem/
+.ipfs/
+.npm/
+.vm*/
+go/pkg
diff --git a/.bashrc b/.bashrc
index c222116..f4a4278 100644
--- a/.bashrc
+++ b/.bashrc
@@ -40,6 +40,7 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date
export TERMINAL=xt
+alias bu='backup -uvd bip:/home/backup/m1'
#alias cl='cf xft:Mono:size=12'
#alias cp='cp --reflink'
#alias ls='ls --color=auto -v'
diff --git a/bin/backup b/bin/backup
index 72c69c3..adce78d 100755
--- a/bin/backup
+++ b/bin/backup
@@ -1,8 +1,6 @@
#!/bin/sh
# Incremental backup using rsync(1).
-[ "$USER" = root ] || exec sudo "$0" "$@"
-
backup() {
date=$(date +%Y%m%d_%H%M%S)
last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1)
@@ -12,25 +10,29 @@ backup() {
(*) opt_link=;;
esac
- rsync -HSxa$optv --exclude-from=$ignore $opt_link / /boot "$dest/$date"
+ rsync -HSxa$optv --exclude-from=$ignore $opt_link $volumes "$dest/$date"
}
dest=/.history
-ignore=/etc/backup/ignore
+ignore=/etc/backupignore
+volumes='/ /boot'
-while getopts :d:i:nv opt; do
+while getopts :d:i:nuv opt; do
case $opt in
(d) dest="$OPTARG" ;;
(i) ignore="$OPTARG" ;;
(n|v) optv="$opt$optv" ;;
- (*) echo "Usage: $0 [-nv] [-d [host:]dir] [clean|diff]"; exit 1 ;;
+ (u) optu=1 volumes="$HOME" ignore="$HOME/.backupignore" ;;
+ (*) echo "Usage: $0 [-nuv] [-d [[user@]host:]dir] [clean|diff]"; exit 1 ;;
esac
done
shift $((OPTIND - 1))
+[ "$optu" ] || [ "$USER" = root ] || exec sudo "$0" "$@"
+
[ "$1" ] && cmd=$1 && shift || cmd=""
case $cmd in
(""|save) backup ;;
-(clean) exec backup-clean ${optv+-$optv} "$dest";;
+(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";;
(diff) exec diffdir "$@";;
esac