Automatic remote backup using cron and #OwnCloud

By | November 20, 2017

Setting up a backup is important and at the same time the most neglected task. One quick solution for a remote backup is using OwnCloud.
If you already have your OwnCloud server or just an account the following short steps can be done.

STEP 1: Gather your data
Lets gather the data to be back-ed up. In my case I just want to make sure my named volumes from a docker environment are safely stored on a remote OwnCloud. I also want them to be saved daily as they change every day.

The following creates an archive having the date in the name, so basically creating a separate archive of each day.

STEP 2: Upload data to the cloud

OwnCloud supports data upload using POST calls to a webdav resource. A simple curl call will do the job.

Where: myUser:myPassword represents the authentication credentials created for this job. It is better to have a separate user just to be easy to manage the files on the server.

STEP 3: Automate the procedure.

To automate the procedure we will use cron.

Just create a bash script backup.sh under /etc/cron.daily

Note1:
1. Make sure that the script is executable and has the right permissions
2. Make sure to remove any .sh extension (in my case is simply renamed as backup)
3. To check if the script is correctly setup execute

If you see your script in the list then all is good.

This will make sure that the above backup.sh will be executed every day and save an archive of /var/lib/docker/volumes to OwnCloud.

Contribute to this site maintenance !

This is a self hosted site, on own hardware and Internet connection. The old, down to earth way 🙂. If you think that you found something useful here please contribute. Choose the form below (default 1 EUR) or donate using Bitcoin (default 0.0001 BTC) using the QR code. Thank you !

€1,00

Advertisements

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.