Git Product home page Git Product logo

rsnapshot-docker's Introduction

rsnapshot in Docker

This Docker image allows you to run a (continuous) rsnapshot backup. The logic is to perform a local backup from either a local folder or a remote server.

It allows the following customization:

Volumes

Using the volume /backup you provide the target folder for the backups. This is mandatory, otherwise backups are done into the ephemeral container disk space.

Using the volume /data you can provide the data which shall be backed up. This is necessary for performing backups from a local folder and can be ignored for remote backups.

File Mounts

The Docker image also expects a few file mounts. They are optional.

Using the volume /ssh-id you can provide at runtime an SSH ID. This is necessary for performing backups from a remote server and can be ignored for local backups.

Using the volume /backup.cfg you can add more backup steps. The content is a list of backup statements (or other statements from the rsnapshot configuration file).

Environment

BACKUP_NAME This is the name of the backup source you are backing up. Default is localhost and it will be used as the name of the subfolder (under the daily.X etc folders) in the /backup volume.

BACKUP_SOURCE This is the name of the backup source you are backing up. Default is /data which matches the name of the expected volume for local backups; for remote server backups the syntax should be user@server:/folder.

BACKUP_OPTS This allows you to add further rsnapshot options to the backup. The default value is one_fs=1 which will make the backup not cross over filesystems.

BACKUP_SSH_ARGS This allows you to provide additional values for ssh_args. One example could be providing a non-standard port with -p 222.

BACKUP_HOURLY This specifies the number of hourly backups to keep. The default value is 0 which means no hourly backups are performed.

BACKUP_DAILY This specifies the number of daily backups to keep. The default value is 3.

BACKUP_WEEKLY This specifies the number of weekly backups to keep. The default value is 3.

BACKUP_MONTHLY This specifies the number of monthly backups to keep. The default value is 3.

BACKUP_YEARLY This specifies the number of yearly backups to keep. The default value is 3.

CRON_HOURLY This specifies the crontab pattern when the hourly backup shall be performed. The default value is 0 * * * *, i.e. every full hour. This setting only is relevant if BACKUP_HOURLY is set to a non-zero value.

CRON_DAILY This specifies the crontab pattern when the daily backup shall be performed. The default value is 30 23 * * *, i.e. at 23:30 (11:30 pm) every night. This setting only is relevant if BACKUP_HOURLY is set to a non-zero value.

CRON_WEEKLY This specifies the crontab pattern when the weekly backup shall be performed. The default value is 0 23 * * 0, i.e. at 23:00 (11pm) every Sunday. This setting only is relevant if BACKUP_WEEKLY is set to a non-zero value.

CRON_MONTHLY This specifies the crontab pattern when the monthly backup shall be performed. The default value is 30 22 1 * *, i.e. at 22:30 (10:30 pm) every first of the month. This setting only is relevant if BACKUP_MONTHLY is set to a non-zero value.

CRON_YEARLY This specifies the crontab pattern when the yearly backup shall be performed. The default value is 0 22 1 1 *, i.e. at 22:00 (10pm) every first January. This setting only is relevant if BACKUP_YEARLY is set to a non-zero value.

Example

Perform local backup of /etc, into /srv/backup, naming it etc-folder:

docker run -d -v /etc:/data -v /srv/backup:/backup \
           -e BACKUP_NAME=etc-folder helmuthb/rsnapshot 

Perform remote backup of a remote server example.com, filesystem /home into /src/backup, naming it remote:

docker run -d -v $HOME/.ssh/id_rsa:/ssh-id \
           -v /srv/backup:/backup \
           -e BACKUP_NAME=remote \
           -e [email protected] \
           helmuthb/rsnapshot

Add a local configuration file backup.cfg with more backups:

backup		/etc	etc-folder/
backup		/boot	boot-folder/
backup		/home	home-folder/
docker run -d -v backup.cfg:/backup.cfg -v /srv/backup:/backup \
           -e BACKUP_NAME=root -e BACKUP_SOURCE=/ helmuthb/rsnapshot

rsnapshot-docker's People

Contributors

codingsteff avatar edwsec avatar helmuthb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rsnapshot-docker's Issues

No change files but rsnapshot is taking up bandwith

@helmuthb

As you know, I have your container setup on my Synology NAS and pulling data from a remote system (through a VPN tunnel) through SSH. Everything is working fine and is following the default schedules of the container however I noticed the daily job yesterday (IIRC it's 11:00PM daily) was still taking bandwidth (maxing the 200Mbps link between the two sites) even though there were technically no files/folders changed in the source directory. How do we start troubleshooting this? I was thinking of checking the logs but I can't find a way to enable rsnapshot logging in your container?

Does not backup some important folders (e.g. /home and /var)

So I'm trying to setup and use your container and here's how I have it setup in my docker-compose.yml file:

rsnapshot:
    image: helmuthb/rsnapshot
    container_name: rsnapshot
    volumes:
      - /mnt/storage/backup:/backup
      - /:/data
      - /home/kevin/appdata/rsnapshot/backup.cfg:/backup.cfg
    restart: unless-stopped
    environment:
      - PUID=0
      - PGID=${PGID}
      - TZ=Asia/Manila

A couple of questions/concerns:

  1. Is the PUID environment variable necessary to be set to 0 (root) so that it will have all permissions to the whole local filesystem?
  2. I tried running "docker exec -it rsnapshot rsnapshot daily" and it did backup most of the folders in my local root filesystem but the /home and /var folder do not have any contents at all. Why is this? I checked the rsnapshot.conf file insider the container and it had these:

config_version  1.2
snapshot_root   /backup/
no_create_root  1
cmd_cp          /bin/cp
cmd_rm          /bin/rm
cmd_rsync       /usr/bin/rsync
cmd_ssh         /usr/bin/ssh
ssh_args        -i /ssh-id -o StrictHostKeychecking=no
verbose         1
lockfile        /var/run/rsnapshot.pid
backup          /data   localhost/      one_fs=1
retain  daily   3
retain  weekly  3
retain  monthly 3
retain  yearly  3

So it looks like everything is setup correctly. I even checked the contents of /data from inside the container and everything was there.
`

Non-root docker user, docker compose and health ping

Hi Helmuth! Thanks for the nice work in this repo.

I used it to implement a customized solution to create remote backups of MediaWiki instances, based on rsnapshot: https://github.com/maxfrei750/MediaWikiBackup

While doing so, I implemented a few features that may (or may not ๐Ÿ˜…) be interesting to you:

  • Running as a non-root docker user, which was surprisingly cumbersome, because of cron. I read in #8 that this might mess with permissions when creating a local backup. For my application that's no problem, because it always runs remote, but I think we could work around this limitation, by mapping the user into the container using docker compose.
  • Using docker compose. I like it, because I can set all the settings in the docker-compose.yaml and it makes starting the container a breeze.
  • I added a way to send a ping to a health check site like healthchecks.io (I'm not affiliated with them). IMHO, very helpful for backups. This could be extended to allow users to make use of the pre- and post- hook of rsnapshot. Although I think that should be possible with your code already.

Feel free to take anything that you deem helpful from my code and of course, I'm happy to answer questions, if necessary. If none of the things are of interest, then just close this issue. ๐Ÿ˜‰

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.