Backup Any Rclone Remote to Another Using Restic on Fly.io Topics
Use Fly.io to periodically backup one Rclone provider to another using Restic.
If you haven't already, you'll need to sign up for Fly and install the flyctl
application by heading over to fly.io. After you've completed Step 3 you may come back to this guide. To see your FLY_API_TOKEN
run the following command and save the output for later.
flyctl auth token
- Fork this repository (click fork in the top right)
- Go to your new repository's settings >> secrets >> action's secrets
- Create new secrets for each of the following,
See below for examples of a
FLY_API_TOKEN FLY_ORG FLY_APP_NAME FLY_APP_REGION CRON_SPEC RESTIC_PASSWORD RESTIC_PRUNE_ARGS RCLONE_CONFIG RCLONE_FROM RCLONE_TO
CRON_SPEC
,RCLONE_CONFIG
,RCLONE_FROM
, andRCLONE_TO
. - Now go to your repositories "Actions" tab. You should see one action, (re)deploy restic.
- Click on (re)deploy & enable the workflow for your fork.
- Now manually run your workflow by clicking "Run Workflow" on the right of the screen. Your workflow should now begin and automatically deploy your Restic app.
- Clone this repository
- Run the following commands, replacing
{{ VALUE }}
with your specifc values.flyctl launch --name {{ YOUR-APP-NAME }} rm fly.toml cd restic sed -i "s\%fly_app_name%\{{ YOUR APP NAME }}\g" fly.toml sed -i "s\%rclone_from%\{{ RCLONE_FROM }}\g" fly.toml sed -i "s\%rclone_to%\{{ RCLONE_TO }}\g" fly.toml sed -i "s\%restic_password%\{{ RESTIC_PASSWORD }}\g" fly.toml sed -i "s\%restic_prune_args%\{{ RESTIC_PRUNE_ARGS }}\g" fly.toml
- Copy your rclone.conf to this
restic/
. - Create a file named
entry-cron
withinrestic/
that defines the cron job to be run with rclone and restic. (See below for an example of a cron definition.) - Run
flyctl deploy
0 */6 * * * restic -r rclone:$RCLONE_TO backup --verbose /data && \
restic -r rclone:$RCLONE_TO check && \
restic -r rclone:$RCLONE_TO forget --prune $RESTIC_PRUNE_ARGS
This example creates a backup snapshot of the RCLONE_TO
data, checks previous backup integrety, and prunes old backups every 6 hours.
[nextcloud]
type = webdav
url = https://instance.domain.tld/remote.php/dav/files/username/
vendor = nextcloud
user = username
pass = rEdAcTeD
[s3]
type = s3
provider = a-provider-or-other
access_key_id = rEdAcTeD
secret_access_key = rEdAcTeD
endpoint = s3.region.provider.tld
This example shows webdav and s3 providers for rclone. You can generate this file by running,
rclone config
Then copy the generated file from $HOME/.config/rclone/rclone.conf
into restic/rclone.conf
.
nextcloud:/
s3:bucket-name/
Copyright 2022 Alec Scott hi@alecbcs.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.