Simple backup rotation script.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Simple Python 3 script for rotating your backups.


  • Create backups/backup rotations of multiple directories
  • Define different settings for every backup source
  • Support for diffrent compression methods
  • Logging


  • Python 3


  1. Download the on your server and create a configuration file.

  2. Test the script and your configuration.

     python3 -c [path to your config.json]
  3. Add a cronjob, so the script runs daily.

     crontab -e

    Put the following line into your crontab. This will run the script every day 1 hour after midnight.

     0 1 * * * python3 -c [path to] -q

    Want some log files? Check out our parameters.


You can use some parameters to create log files or disable console output.

Parameter Description Default
-c <path> <path> to your configuration file config.json in the same directory
-l <path> <path> to your logfile no log output
-lv <level> Specifies the loglevel for your logfile 1
-q Quiet, no console output


  • Loglevel 0: Debug messages
  • Loglevel 1: Generic information
  • Loglevel 2: Warnings (e.g. backupitem invalid)
  • Loglevel 3: Errors (e.g. config not found)


The configuration of is stored in a .json-file. To get started, just copy or download the default-config.json on your server.


Valid options

Key Target Description
create_backup_day_of_week default and backup_item The day of the week on which to create a backup
create_backup_day_of_month default and backup_item The day of the month on which to create a backup
create_backup_day_of_year default and backup_item The day of the year on which to create a backup
daily_backups default and backup_item Count of how many daily backups to keep
weekly_backups default and backup_item Count of how many weekly backups to keep
monthly_backups default and backup_item Count of how many monthly backups to keep
yearly_backups default and backup_item Count of how many yearly backups to keep
compression default and backup_item Compression type (Supported types: gz, xz and bz2)
source backup_item Source directory of backup
destination backup_item Destination directory of backups

Default section

All values inside of the defaultarray are used as default values. These values are used unless otherwise defined by a backup item.

Backup_items section

backup_items is a array containing multiple backup_items. One backup_item has to have the keys source and destination. All other values are optional.


Check out the example-config.json for more config samples.