summaryrefslogtreecommitdiff
path: root/linode/backup.sh
blob: 00ff1b2721c3b80a4e5273038fbc594331e07749 (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
#!/bin/sh

cd /

DEST=data/backup
SQL=tmp/dump-$$.sql
PKGS=tmp/pkglist-$$

SOURCE="home/ianc etc usr/local/etc usr/local/svn usr/local/svn-private $SQL $PKGS"

BACKUP=$DEST/$(date +%Y%m%d).tar.gz

echo Dumping database
mysqldump -u root --password=$(cat /usr/local/etc/mysqlpassword) --all-databases > $SQL

echo Dump installed packages
/usr/local/bin/listinstalledpkgs.sh > $PKGS

echo Backing up to $BACKUP

tar cfz $BACKUP $SOURCE

rm -f $SQL

cd $DEST
echo Clearing old files
find . -mtime +10 -print -exec rm {} \;