summaryrefslogtreecommitdiff
path: root/scripts/back
blob: 3ad94288bb352e7f92c95f1bb04ac24aa8166cb0 (plain)
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
42
43
44
45
#!/bin/sh
echorun()
{
	echo $@
	$@
}
check_commands()
{
	for cmd in $@ ; do
		if [ ! `which $cmd` ] ; then
			echo "$cmd doesn't exist"
			exit
		fi
	done
}

check_commands ssh tar rsync

if ! ssh -q "$1" exit ; then
	echo "first argument should be valid ssh connection"
	exit
fi

dirs='
books
log
music
pictures
projects
studies
'
start=$PWD
today=`date +%d_%m_%Y`

echorun cd $HOME
for dir in $dirs ; do
	if [ -d $dir ] ; then
		tarname="$dir"_"$today".tar
		echorun tar cf $tarname $dir
		echo rsync -avz --progress $tarname $1:backups
	else
		echo "$dir doesn't exist"
	fi
done
echorun cd $start