Build Duplicacy from source

Duplicacy is written in Go. If you have Go installed you can run the following command to build from the latest source:

The following information is not currently accurate. See this post from the developer.

go get -u github.com/gilbertchen/duplicacy/...

The executable named duplicacy will then be created under $GOPATH/bin.

You can also build the executable manually after running the go get command.

cd $GOPATH/src/github.com/gilbertchen/duplicacy
go build duplicacy/duplicacy_main.go

The executable will be created under $GOPATH/src/github.com/gilbertchen/duplicacy with the name duplicacy_main.

To download the pre-built executable, please visit the releases page and select the binary that works for your platform.

Longer explanation of how to build from source

Click here

:warning: Buliding from source from a different branch is no easy task, so i think you shouldn’t do it if you don’t know git. Just take my word on it please.

:warning: :warning: : Note that i’m not giving any tips on how to git. Git is a complex program which can’t be explained in a short tutorial. If you try it you will need help. This tutorial will not teach you git. Git is between you and google – this is why i suggested sourcetree below.

:white_check_mark: If you just want to build duplicacy without any other bells and whistles (for example just to change 1 or 2 parameters like number of retries) then you don’t need to worry: all is presented below.

  1. help:

  2. download and install go and git and make them available in PATH

  3. set $GOPATH to whichever directory you want to use as workspace (if you don’t do this, go uses as default location your_homefolder/go )

  4. in cmd run go get github.com/gilbertchen/duplicacy/duplicacy
    3.5 wait until the command finishes (it has to download A LOT) of sources needed for building duplicacy (all the libraries which duplicacy depends on – for each supported storage and so on)

  5. after the download is finished, cd to the folder $GOPATH/src/github.com/gilbertchen/duplicacy (see the similarity with the above github path? → this is how go manages libraries and dependencies). There are all the sources for duplicacy.

    • 4.5 if you want to build a different branch from master, now it’s the time! you have to pull the remote branch which has the changes you need into local master – I recommend using a good GUI: Sourcetree but you can do it from cmd as well. (you monster).
    • 4.6 If you want to modify something in the sources, you should do it at this step (eg.: modify the number of retries for some storage)
  6. now that you have the sources, you have to actually compile duplicacy: again in cmd go install github.com/gilbertchen/duplicacy/duplicacy

  7. compiling should take no more than 10 seconds. You will find the executable file in the folder $GOPATH/bin/duplicacy.exe

Congratz!

Build on macOS

To build from source on macOS, Xcode must be installed because one of the dependency libraries, github.com/gilbertchen/keyring requires cgo for security reasons (see #136 for details). If you don’t want to install Xcode, you can switch to github.com/tmc/keyring (the original library that github.com/gilbertchen/keyring was forked from) by modifying this line in src/duplicacy_keyring.go:

    "github.com/gilbertchen/keyring"

to

    "github.com/twc/keyring"

Build from a fork

If you fork the repository github.com/gilbertchen/duplicacy and clone the fork locally as github.com/yourusername/duplicacy,
please remember that duplicacy/duplicacy_main.go still imports from github.com/gilbertchen/duplicacy/src,
so any changes you make under github.com/yourusername/duplicacy/src will have no effect when building the executable.

Option 1

Therefore, the recommended way is to clone your fork into the original namespace:

git clone https://github.com/yourusername/duplicacy $GOPATH/src/github.com/gilbertchen/duplicacy
Option 2

There is one other option when working with a fork which is explained fully here.
The short version is:

  1. Make a normal github fork of duplicacy (so that you have github.com/you/duplicacy);
  2. Clone original duplicacy: go get github.com/gilbertchen/duplicacy, and not your fork;
    • The repository is locally @ cd $GOPATH/src/github.com/gilbertchen/duplicacy;
  3. Add a remote to your fork in the cloned repository git remote add fork https://github.com/you/duplicacy noted above;
  4. Instead of committing/pushing to origin (which is the original github.com/gilbertchen/duplicacy),
    now you use fork (which is your github repository github.com/you/duplicacy).

In this way, it is also very easy to test other people’s code: just add a new remote to $GOPATH/src/github.com/gilbertchen/duplicacy
(the original duplicacy clone) like you did in step 3. But just change the name fork to something else.

Note about the second method: there is no clone of github.com/you/duplicacy therefore there shouldn’t exist on your disk any folder
$GOPATH/src/github.com/you/duplicacy.

Cross compile

An example for some NAS boxes - ARM, Debian with 64k pages:

cd $GOPATH/src/github.com/gilbertchen/duplicacy
env GOARCH=arm GOOS=linux go build -o duplicacy_linux64k_arm --ldflags "-R 65536" -v duplicacy/duplicacy_main.go

I have a builder that I use to do development that can be used with the original sources, too: GitHub - markfeit/duplicacy-dev: An easy-to-set-up environment for Duplicacy development

It’s been tested on Linux but should also work on OS X.

3 Likes

On MacOS there is a very quick alternative route.

  1. Install MacPorts. Likely you already have them.

  2. Update ports:

    sudo port selfupdate
    sudo port -N upgrade outdated

  3. Install go. This will bootstrap and build latest golang

    sudo port -N install golang

  4. Go get duplicacy

    go get -u github.com/gilbertchen/duplicacy/

1 Like

Thank you for this! Works as expected.

1 Like