Compress and backup multiple directories into multiple rclone remotes
Find a file
2026-05-30 11:16:53 -06:00
.gitignore Initial commit 2025-11-26 22:04:13 -06:00
LICENSE loicence 2025-11-26 23:35:24 -06:00
main.py glob patterns 2026-05-30 11:16:53 -06:00
README.md Add readme 2026-05-11 23:49:45 -06:00

Rclone-Backuper

This script reads a list of directories, compresses each one, then copies them to each rclone remote specified.

Theres also an option to stop all docker containers with a specific label, then restarting them after the backup finishes.

The compressed archives are saved as PARENTDIR-DIR.tar.gz

Recommended to run the script periodically (with a cron job or a systemctl service)

Supported Python Versions: 3.6+ Requirements: No Python libraries, rclone installed and available. tar installed and available. docker only needed if stopping containers (or you can specify your own container runner)

Configuration

Make a directory in this script's location with the name conf

The script reads conf/directories.list, conf/excludes.list, and conf/remotes.list

Lines starting with # are ignored

directories.list

The list of directories to compress and backup. Absolute paths are recommended. (Note: make sure the user running the script has full permissions for these directories)

# Example directories.list
/home/user/Documents
/home/user/Pictures
/mnt/Drive

remotes.list

The list of rclone remotes to backup to.

# Example remotes.list
google-drive:
backblaze:Backup
hddcrypt:Server/Backup

excludes.list

The list of files/directories to exclude, used by tar. The script's temp and log directory are automatically exlcuded.

# Example excludes.list
/home/user/Downloads
/home/user/Projects/*/venv
*/.var/app/com.valvesoftware.Steam/data/*

Environment Variables

(note: the script doesnt read .env files)

  • DRY_RUN - If set to true, adds the --dry-run parameter to the rclone copy command (Default: false)
  • STOP_CONTAINERS - If set to true, will stop all containers before the backup, then restart them after. (Default: false)
  • STOP_CONTAINERS_LABEL - If set, and STOP_CONTAINERS is on, wlll only stop containers with this label. Otherwise, stop all containers.
  • DOCKER_EXECUTABLE - The executable to use for managing containers, override to use a different container runtime, must be compatiable with docker stop, ps, restart commands. (eg. podman) (Default: docker)
  • RCLONE_TRANSFERS - Sets the --transfers parameter on the rclone command for faster speeds. (Default: 16)
  • SUBPROCCESS_TIMEOUT - Sets the timeout for subproccesses (For things like compressing and rclone). Set to -1 for no timeout. (Default: 3600)
  • STREAM_LOG_LEVEL - Sets the logging level for the console (Default: INFO)
  • FILE_LOG_LEVEL - Sets the logging level for the logfile (Default: DEBUG)