Rcloner

README in progress. Project is on the early stage, use it at your own risk.

Simple wrapper for Duplicity (with optional Rclone backend) which allows to sync/restore your application files/database from a remote storage. All files stored on a remote storage are encrypted and backups are incremental, thanks to Duplicity.

Example config (rcloner.yml)

origin: /home/deploy/myapp
destination: webdavs://login:[email protected]/myapp_backup
include:
  - 'public/images'
  - 'config/master.key'
  - '.env'
  - 'tmp/db.dump'
on_backup:
  before: 'postgressor dumpdb tmp/db.dump'
  after: 'rm tmp/db.dump'

Where:

  • origin is the root folder path if your application. If not provided - current directory will be taken. Can be also provided as RCLONER_ORIGIN env variable.
  • destination - remote path in dyplicity format. Can be also provided as env variable RCLONER_DESTINATION.
  • include if provided - only this paths will be taken for backup, not the whole origin. Urls should be provided in relative paths to origin folder.
  • on_backup (before/after) custom optional commands/scripts to execute before/after backup. Commands will be executed into origin directory.

Note that rcloner by default loads env variables from .env file (if exists) in current category.

Installation

1) Install rclone:

$ curl https://rclone.org/install.sh | sudo bash

2) Install duplicity, minimal supported version is 0.8.09. If you're using Ubuntu, the most simple way to install latest version is via snap:

$ sudo snap install duplicity --classic

3) Install gem rcloner:

$ gem install rcloner

Or you can install gem directly from github using specific_install:

$ gem install specific_install
$ gem specific_install https://github.com/vifreefly/rcloner

Another option is to add gem to your application Gemfile:

gem 'rcloner', git: 'https://github.com/vifreefly/rcloner', require: false

Usage

Readme in progress...

backup

To sync all items from local to remote rclone storage use backup command:

deploy@server:~/my_app$ rcloner backup --config rcloner.yml

restore

To sync all items from remote rclone storage to local server use restore command:

deploy@server:~/my_app$ rcloner restore --config rcloner.yml

How to run backup with a cron

Use Whenewer gem.

Notes

License

The gem is available as open source under the terms of the MIT License.