-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbu
More file actions
executable file
·41 lines (33 loc) · 954 Bytes
/
bu
File metadata and controls
executable file
·41 lines (33 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env rc
test $BACKUPDIR || BACKUPDIR=/usr/local/backup/$USER
test $BACKUPDEST || BACKUPDEST=regenfus@lxhalle.in.tum.de:/u/halle/regenfus/home_at/backup
cd $BACKUPDIR
name=`{date '+%Y-%m-%d.tar.gz'}
last=`{stat --format'=%Y %n' * | sort -n | awk 'END { print($2) }'}
month=`{date '+%m'}
lastmonth=`{printf '%s\n' $last | sed 's/^[0-9]\+-\([0-9]\+\).*/\1/'}
if(test -f $name.enc)
exit 0
if(test -f $name) {
~ `{date +'%Y-%m-%d'} `{stat --format'=%y' $name | awk '{ print($1) }'} && exit 0
rm $name
}
if(test -d tmp/){
~ `{date '+%Y-%m-%d'} `{stat --format'=%y' tmp/ | awk '{ print($1) }'} && exit 0
rm -rf tmp/
}
mkdir tmp
if(! ~ $month $lastmonth)
cp -R $HOME/* tmp/
if not
cgdc $BACKUPDIR/$last $HOME/ $BACKUPDIR/tmp/
test -f tmp/.gnupg/random_seed && rm tmp/.gnupg/random_seed
cd tmp
tar -czf $name *
mv $name ..
cd ..
rm -rf tmp
chmod 0600 $name
fenc e '!'^`{spm show backup} $name $name.enc
rm $name
scp $name.enc $BACKUPDEST