Introduction
Duplicacy is state-of-the-art backup tool that has extensive cloud support. It also supports local disks and remote sftp servers.
Duplicacy is available as a web-based GUI or as a command line tool.
The software does require a license but the command-line interface (CLI) version is free for personal use.
We’ll be using the CLI version for this tutorial.
Installation
Packages
Pre-compiled binaries are available for Linux, macOS, and Windows directly from the Duplicacy GitHub repository.
Download the latest version for your system. Currently the latest version is version 2.7.2
.
$ wget https://github.com/gilbertchen/duplicacy/releases/download/v2.7.2/duplicacy_linux_x64_2.7.2
Make the file executable.
$ chmod +x duplicacy_linux_x64_2.7.2
Rename the file to duplicacy.
$ mv duplicacy_linux_x64_2.7.2 duplicacy
Change the file permissions.
$ chmod 755 duplicacy
Move the file to the /usr/bin directory.
$ sudo mv duplicacy /usr/bin/
Preparing a new repository
The directory that you want to backup is called a repository
. The location where your backup will be stored is called the storage url
.
The duplicacy init command is used to initialize the storage location and the backup directory.
duplicacy init [command options] <snapshot id> <storage url>
The <snapshot id>
refers to the name you want to call your backup job.
The <storage url>
refers to the storage location for your backup job.
Run the duplicacy init command to see a full list of options.
$ duplicacy init
StorJ cloud storage
Storj is an S3 compatible cloud storage provider that offers 150 GB of free storage. No credit card is required.
In order to backup data via Storj, you must first create a bucket and S3 credentials on their website with your account.
- Sign up for a free account to get started.
- Create a new storage bucket.
- Create your S3 credentials.
You will need the name of your bucket and the Access key ID and Secret access key from your S3 credentials file to initialize the repository.
An example should make this easier to understand.
The duplicacy init command has a lot of options, but we’ll only be using the following:
-encrypt, -e encrypt the storage with a password
-storage-name <name> assign a name to the storage
-repository <path> initialize a new repository at the specified path
The format will look like this:
$ duplicacy init -e -storage-name <storage name> -repository <directory to be backed up> <storage url>
For our example, I’ve created a storage bucket called documentbackup and I will be backing up my documents folder.
I will use storjdocs for the storage name
and documentbackup as the name of the <storage id>
.
Most S3 cloud storage use a Gateway endpoint
for connecting. Storj’s gateway endpoint is gateway.storjshare.io
.
You will also need to specify the regional location. For my location this would be us-east-1
.
You will need to specify both the gateway endpoint and the regional location as part of the <storage url>
.
Here is the complete command:
$ duplicacy init -e -storage-name storjdocs -repository /home/curt/Documents documentbackup s3://[email protected]/documentbackup
You will see the following prompts:
Enter S3 Access Key ID:
Enter S3 Secret Access Key:
Enter storage password for s3://[email protected]/documentbackup:***********
Re-enter storage password:***********
/home/curt/Documents/ will be backed up to s3://[email protected]/documentbackup with id documentbackup
- Type in your
S3 Access Key ID
. - Type in your
S3 Secret Access Key
. - Type in a storage password you wish to use.
Saving configuration information
Duplicacy automatically creates a configuration folder named .duplicacy
after the initialization is completed.
Duplicacy stores it’s configuration information in the .duplicacy/preferences
file.
The duplicacy set command is used to save your keys, passwords, etc in this configuration file so you don’t have to supply them manually when running a backup or restoring files. This also allows you to automate your backups with bash scripts and to schedule them via cron jobs.
duplicacy set -storage <storage name> -key -value
For the full list of environment variables that can be set in the preferences file see the official Duplicacy forum .
We’ll be setting the following variable keys:
<storagename>_password
<storagename>_s3_id
<storagename>_s3_secret
The variable key
needs to be all lowercase and with double quotes. The value
variable needs to be in single quotes.
Here is the complete command for our example:
$ duplicacy set -storage storjdocs -key "storjdocs_password" -value 'mystoragepassword'
$ duplicacy set -storage storjdocs -key "storjdocs_s3_id" -value 'myS3IDkey'
$ duplicacy set -storage storjdocs -key "storjdocs_s3_secret" -value 'myS3secretkey'
Backing up
Now we’re ready to backup our data using the duplicacy backup command.
duplicacy backup -storage <storagename>
Here is the complete command using our example:
$ duplicacy backup -storage storjdocs
$ duplicacy backup -storage storjdocs
Repository set to /home/curt/Documents
Storage set to s3://[email protected]/documentbackup
No previous backup found
Indexing /home/curt/Documents
Parsing filter file /home/curt/.duplicacy/filters
Loaded 0 include/exclude pattern(s)
Listing all chunks
Packed auto.sh (483)
Packed server.odt (18752)
Packed test.sh (164)
Packed test2.sh (218)
Packed s3access/gcd-token.json (601)
Packed s3access/s3accessinfo.txt (869)
Packed s3access/s3keys.txt (870)
Packed s3access/test.log (24)
Backup for /home/curt/Documents at revision 1 completed
Duplicacy assigns and increments a revision number every time you re-run the backup.
Here is what a second backup will look like if there are no file changes.
$ duplicacy backup -storage storjdocs
Repository set to /home/curt/Documents
Storage set to s3://[email protected]/documentbackup
Last backup at revision 2 found
Indexing /home/curt/Documents
Parsing filter file /home/curt/.duplicacy/filters
Loaded 0 include/exclude pattern(s)
Backup for /home/curt/Documents at revision 2 completed