
This guide shows you how to install and setup a backup system with incremental backups on Linux Debian based system using Tartarus with your own FTP Server. This guide also contains a bash script which automates the whole process of installing and configuring Tartarus.
Tartarus is a software that provides a nice wrapper around basic Unix tools such as tar, find and curl (well, that’s not that basic) to provide a seamless backup solution, aimed at automatic gathering and backup. It has the ability to do full as well as incremental backups and is published by Stefan Tomanek under the rules of the GPL.
Instead of relying on single usage backup scripts or complicated command lines, “tartarus” reads its configuration from easily managable configuration files. It can store gathered data in regular files, or upload the backup directly (on the fly) to an FTP server. For more specific usage scenarios, custom methods can also be defined within the config file.
Click like to add us to your Facebook News Feed
Installation
Debian users can install the program also easily use the packaging system and keep it current by adding the following line to your APT configuration. Than is create a file called /etc/apt/sources.list.d/tartarus.list and add the following line:
Import the GnuPG key with which the repository is signed, and to install the program
wget -O - http://wertarbyte.de/apt/software-key.gpg | apt-key add -
apt-get update
apt-get install tartarus
The script uses a variety of classic Unix tools using the package management – if not already done – Install the following:
Configuration
Tartarus reads its configuration profile files that are stored in the / etc / tartarus. These are shell scripts that are processed by the backup process, so it is also possible to include on the command “source” other configuration files in a profile. This can be exploited to store generic settings for all profiles backup central
Create tartarus general config:
Edit the settings in the config:
# Generic settings for the backup
# Storage method
STORAGE_METHOD = "FTP"
# Address of the FTP server
STORAGE_FTP_SERVER = "yourftpserver.com"
# FTP access
STORAGE_FTP_USER = "your ftp user account"
STORAGE_FTP_PASSWORD = "users password"
#Compression method
COMPRESSION_METHOD="bzip2"
# Backup data encrypt symmetrically
ENCRYPT_SYMMETRICALLY = "yes"
# Password from / etc / tartarus / backup.sec read
ENCRYPT_PASSPHRASE_FILE = "/etc/tartarus/backup.sec"
# While the backup was not
# File system limits beyond
STAY_IN_FILESYSTEM = "yes"
# Helper script Charon which removes stored
# backups exceeding a specific age and is
# included in the tartarus distribution package.
# Hook in Charon
TARTARUS_POST_PROCESS_HOOK() {
# pass configuration variables to charon
# transmit the password through stdin to hide it from "ps ax"
local CHARON="/usr/sbin/charon.ftp"
local MAX_AGE_IN_DAYS="7"
echo -n "$STORAGE_FTP_PASSWORD" | $CHARON \
--host "$STORAGE_FTP_SERVER"
--user "$STORAGE_FTP_USER" -- readpassword \
--maxage "$MAX_AGE_IN_DAYS" \
--dir "$STORAGE_FTP_DIR" --profile "$NAME"
}
# Logging to syslog
TARTARUS_DEBUG_HOOK() {
echo $DEBUGMSG | logger
}
Note*: In the end of the generic.inc configuration file I have added a post process hook. This hook is run after the backup has been carried out and delete backups which are older than 7 days. This is a nice feature so you don’t waste your storage with old backups.
Create a file with your pass phrase. You can create a pass phrase by using the program pwgen or choose your own. Add to the following file.
Backup
Create a backup operation: A simple profile for the Safety of the root file system (/) might be:
Create backup config file:
Use these settings
source /etc/tartarus/generic.inc
# Profile name
NAME="root"
# What to backup
DIRECTORY="/"
# To exlude
EXCLUDE="/tmp/ /proc/ /sys/ /var/tmp/ /var/run/"
# No LVM snapshot
CREATE_LVM_SNAPSHOT="no"
INCREMENTAL_TIMESTAMP_FILE="/var/spool/tartarus/timestamps/root"
Do your fist backup:
Incremental backups
After a full backup you can start incremental backups. Incremental backups saves only the changes since the last full backup. Tartarus creates marker files to determine the exact date of the last backup. To perform incremental backups, you must first create a directory that contains these files:
After each successful backup the script updates the file. To perform an incremental backup, you start Tartarus incremental with the additional parameter “-i”. So to make an incremental backup you would write:
Automatic backup
The best solution is if you don’t have to think about backup and it is done automatically. It is there for a good idea to create a script to run your different backups. Create a shell script and place it in your favorite bin location. Here I have added it to /usr/local/bin
Here is the contents of the shell script. This runs the backup for the profile you choose to run it with. That is for our example tartarus_backup.sh # root. Add this to the file:
# /usr/local/bin/tartarus_backup.sh
# Run all backup profile found in /etc/tartarus/ and pass
# command line arguments on to tartarus (e.g. -i)
for profile in /etc/tartarus/*.conf; do
/usr/sbin/tartarus $* "$profile"
done
Make the script executable:
Now you can run the full backup script by writing and if the shell script is in your PATH you can leave that out.
And to run incremental backup:
Now add the backup task to your crontab. You edit the crontab by writing crontab -e in the prompt. Here is an example on full backup every Sunday and the other days incremental backups.
# m h dom mon dow command
0 3 * * 1-6 tartarus_backup.sh -i # root
0 3 * * 0 tartarus_backup.sh # root
Note*: If you have databases on your server it is a good idea to backup these to the file system. Then they are automatically saved to your backup store when running tartarus backup. Here is a guide on how to backup your MySQL databases:
How to backup your MySQL databases automatically with the script AutoMySQLBackup
Recovery
Since Tartarus is based on simple Unix utilities, a backup is very easy to restore from the rescue system. To unpack the archive in the directory /mnt/restore you do the following:
curl ftp://USER:PASS@YOURSERVER/DIR/FILE | gpg --decrypt | tar xpvj -C /mnt/restore
Setup Tartarus Bash Script
Here is a script which automates the whole process of installing and configure Tartarus:
setuptartarus.sh
# Add Tartarus to your source list
echo -e "\n\n# Tartarus" >> /etc/apt/sources.list
echo "deb http://wertarbyte.de/apt/ ./" >> /etc/apt/sources.list
# Import the GnuPG key with which the repository is signed, and to install the program
wget -O /etc/apt/sources.list.d/wertarbyte.list http://wertarbyte.de/apt/wertarbyte-apt.list
wget -O - http://wertarbyte.de/apt/software-key.gpg | apt-key add -
apt-get update
apt-get install tartarus
# The script uses a variety of classic Unix tools using the package management – if not already done – Install the following
apt-get install tar bzip2 lvm2 gnupg curl
# Create Tartarus dir
mkdir /etc/tartarus/
# Create config file
echo "Enter FTP server address and dir:"
read ftp
echo "Enter FTP user:"
read usr
echo "Enter FTP password:"
read -s pwd
echo "# File: etc/tartarus/generic.inc
# Modified
# / Etc / tartarus / generic.inc
# Generic settings for the backup
# Storage method
STORAGE_METHOD=\"FTP\"
# Address of the FTP server
STORAGE_FTP_SERVER=\"$ftp\"
# FTP access
STORAGE_FTP_USER=\"$usr\"
STORAGE_FTP_PASSWORD=\"$pwd\"
#Compression method
COMPRESSION_METHOD=\"bzip2\"
# Backup data encrypt symmetrically
ENCRYPT_SYMMETRICALLY=\"yes\"
# Password from / etc / tartarus / backup.sec read
ENCRYPT_PASSPHRASE_FILE=\"/etc/tartarus/backup.sec\"
# While the backup was not
# File system limits beyond
STAY_IN_FILESYSTEM=\"yes\"
# Helper script Charon which removes stored
# backups exceeding a specific age and is
# included in the tartarus distribution package.
# Hook in Charon
TARTARUS_POST_PROCESS_HOOK() {
# pass configuration variables to charon
# transmit the password through stdin to hide it from "ps ax"
local CHARON=\"/usr/sbin/charon.ftp\"
local MAX_AGE_IN_DAYS=\"7\"
echo -n \"\$STORAGE_FTP_PASSWORD\" | \$CHARON \\
--host \"\$STORAGE_FTP_SERVER\" \\
--user \"\$STORAGE_FTP_USER\" --readpassword \\
--maxage \"\$MAX_AGE_IN_DAYS\" \\
--dir \"\$STORAGE_FTP_DIR\" --profile \"\$NAME\"
}
# Logging to syslog
TARTARUS_DEBUG_HOOK() {
echo \$DEBUGMSG | logger
}" > /etc/tartarus/generic.inc
# Create root configuration
echo "# Read main config
source /etc/tartarus/generic.inc
# Profile name
NAME=\"root\"
# What to backup
DIRECTORY=\"/\"
# To exlude
EXCLUDE=\"/tmp/ /proc/ /sys/ /var/tmp/ /var/run/\"
# No LVM snapshot
CREATE_LVM_SNAPSHOT=\"no\"
INCREMENTAL_TIMESTAMP_FILE=\"/var/spool/tartarus/timestamps/root\"" > /etc/tartarus/root.conf
If there is a typo in the guide or you have a better solution please post it as comment.
Btw. if you like the post you know what to do ; )





Posted in
Tags:
«







Linux backups don’t have to a pain. A thoughtful backup cron will work for months!
Execellent solution for backup of files. Subscribing. Thanks
Solid solution. Thanks
Thanks for you contribution. This is a backup solution for my needs. Like the site, thumbs up.
nice job. i am using it. still some little problems …
where
–host “$STORAGE_FTP_SERVER”
change to
–host “$STORAGE_FTP_SERVER” \
and another one…
where
mkdir -p /var/spool/tartarus/timestamps/root
it gives a error, and you dont need a directory there so change to:
mkdir -p /var/spool/tartarus/timestamps