Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

Simple Backup Script with logrotate

A simple backup script using logrotate to save multiple backups.

I use a NFS storage mounted via autofs as backup location.

Database Backup is optional.


# Backup Target (Network Share mostly via autofs)

# Number of Backups

# Directories to backup
SOURCE_DIRS="/var/www /var/log /etc"

# Backup
savelog -n -l -q -c $BACKUP_NUM "$BACKUP_DIR/fileBackup.tar"
tar cf "$BACKUP_DIR/fileBackup.tar" $SOURCE_DIRS

# Optional Database Backup
savelog -n -l -q -c $BACKUP_NUM "$BACKUP_DIR/mysql.sql"
mysqldump -u root -pYOURPASSWORD --all-databases > "$BACKUP_DIR/mysql.sql"


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.