diff options
-rwxr-xr-x | linode/backup.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/linode/backup.sh b/linode/backup.sh new file mode 100755 index 0000000..3a5e2e1 --- /dev/null +++ b/linode/backup.sh @@ -0,0 +1,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-%H%S).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 {} \; |