cron can fire all kinds of stuff.
Generally everything that is executable.
I would suggest writing a backup bash script or something.
- dump your database using mysqldump.
- backup your site using rsync or git.
Also: you do not want to backup your stuff on your production-machine. If it breaks everything is gone!
Put your backup cronjob in /etc/cron.d/webbackup with the file-content:
# m h dom mon dow user command
25 6 * * * root path/to/your/backupscript.sh
#
and then write a backupscript.sh like this (this is pseudocode NOT an actual script)
file: backupscript.sh
#!/bin/bash
path/to/mysqldump.sh
rsync -avz /your/website/ username@backupserver:/path/to/backupfolder/
rsync -avz /your/mysqldump/folder/ username@backupserver:/path/to/mysqlbackupfolder/
file: mysqldump.sh (this is not mine but I modified it)
#!/bin/bash
# TARGET: Backup-Ziel
# IGNORE: Liste zu ignorierender Datenbanken (durch | getrennt)
# CONF: MySQL Config-Datei, welche die Zugangsdaten enthaelt
TARGET=/var/backups/mysql
IGNORE="phpmyadmin|mysql|information_schema|performance_schema|test"
CONF=/etc/mysql/debian.cnf
if [ ! -r $CONF ]; then /usr/bin/logger "$0 - auf $CONF konnte nicht zugegriffen
werden"; exit 1; fi
if [ ! -d $TARGET ] || [ ! -w $TARGET ]; then /usr/bin/logger "$0 - Backup-Verze
ichnis nicht beschreibbar"; exit 1; fi
DBS="$(/usr/bin/mysql --defaults-extra-file=$CONF -Bse 'show databases' | /bin/g
rep -Ev $IGNORE)"
NOW=$(date +"%Y-%m-%d")
for DB in $DBS; do
/usr/bin/mysqldump --defaults-extra-file=$CONF --skip-extended-insert --skip
-comments $DB > $TARGET/$DB.sql
done
if [ -x /usr/bin/git ] && [ -d ${TARGET}/.bzr/branch ]; then
cd $TARGET
/usr/bin/git add -A
/usr/bin/git commit -m "$NOW"
else
/usr/bin/logger "$0 - bzr nicht verfuegbar oder Backup-Ziel nicht unter Versio
nskontrolle"
fi
/usr/bin/logger "$0 - Backup von $NOW erfolgreich durchgefuehrt"
exit 0
You will need to look into ssh and ssh-copy-id for this.
There are better solutions like git etc. but this might be something to get you started.
I hope that helped a little...