Yes, but I'd rather setup a script that runs at boot to do the backup.
That's simple
just mount the separate partition into your local filesystem (I have used /backup on my machine) and sync into it.
What I do is to make incremental snapshot-style backups. That means I make hardlink copies of my backed up files so that I have for each backup a "full" backup copy.
backup.sh
Code:
#!/bin/bash
unset PATH
# USER VARIABLES
BACKUPDIR=/backup # Folder on the backup server
MYSQLUSER=root
MYSQLPWD=***************
MYSQLHOST=localhost
MYSQLBACKUPDIR=/mysql_backup
EXCLUDES=/backup/backup_exclude # File containing exludes
DAYS=90 # After how many days shall the backups be deleted?
# PATH VARIABLES
CP=/bin/cp;
MK=/bin/mkdir;
DATE=/bin/date;
RM=/bin/rm;
GREP=/bin/grep;
MYSQL=/usr/bin/mysql;
MYSQLDUMP=/usr/bin/mysqldump;
RSYNC=/usr/bin/rsync;
TOUCH=/bin/touch;
FIND=/usr/bin/find;
## ##
## -- DO NOT EDIT BELOW THIS HERE -- ##
## ##
# CREATING CURRENT DATE / TIME
$MK $BACKUPDIR/current
$MK $BACKUPDIR/old
NOW=`$DATE '+%Y-%m'-%d_%H:%M`
MKDIR=$BACKUPDIR/old/$NOW/
$MK $MKDIR
# CREATE MYSQL BACKUP
# Remove existing backup dir
$RM -Rf $MYSQLBACKUPDIR
# Create new backup dir
$MK $MYSQLBACKUPDIR
#Dump new files
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
$MYSQLDUMP \
-u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST \
-Q -c -C --add-drop-table --add-locks --quick --lock-tables \
$i > $MYSQLBACKUPDIR/$i.sql;
done;
# RUN RSYNC INTO CURRENT
$RSYNC \
-avzp --delete --delete-excluded \
--exclude-from="$EXCLUDES" \
/ \
/$BACKUPDIR/current ;
# UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME
$TOUCH $BACKUPDIR/current
# MAKE HARDLINK COPY
$CP -al $BACKUPDIR/current/* $MKDIR
# REMOVE OLD BACKUPS
for file in "$( $FIND $BACKUPDIR/old/ -maxdepth 1 -type d -mtime +$DAYS )"
do
$RM -Rf $file
done
exit 0
It's very simple that script. First I define a few things (where I want to have backups to, how long I want to keep them, ....)
I also have mysql databases, so I need to back them up also - you probably can just skip that.
Bookmarks