Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/dobackup.sh
blob: 1677776ff831b2777e4503c97c8c99ac71b4f08b (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash


#TODO: test if gnome/dir is not empty before cp!!!!

serial_file=/ofw/serial-number
nickname=`sudo -u olpc gconftool-2 -g /desktop/sugar/user/nick | sed  's/\?//p'`
timestamp=`date +%s`
data=/home/olpc/.sugar/default/datastore
log=backup.log
user_home=/home/olpc/


# copying stderr and stdout in a log file
exec > >(tee -a $log)

echo ---- Starting do_backup script: `date -d @$timestamp` ---- >> $log

if [ -n "$1" ]; then
  data=$1
fi

if [ ! -d "$data" ]; then
  echo "Error, $data does not exists!"
  exit 1
fi

if [ -f "$serial_file" ]; then
  serial=$(cat $serial_file)
else
  serial=$timestamp
fi

dir=$serial
mkdir $dir

echo Backup in progress
echo $nickname > $data/nickname
tar cjf $dir/$dir.bz2 $data 2>/dev/null #&
echo "... Journal done"

# GNOME backup
mkdir $dir/gnome
cp /home/olpc/Mus* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Vid* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/power-logs $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Down* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Desk* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Docu* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Pic* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Ima* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/T* $dir/gnome/ -R 2>/dev/null
cp /home/olpc/Bur* $dir/gnome/ -R 2>/dev/null

echo "... GNOME done"

echo "The backup is in $serial"
echo "" >> $log
echo "" >> $log
/sbin/poweroff