How to install/update/remove duplicacy-web. Linux scripts (intended for newbies) :)

I’ve seen the odd newbie ask how to install :d:web on Linux. I was inspired by @Christoph 's post Automatically update duplicacy web. I don’t think i could have figured out the latest download without his code.

Please remember this is created by a noob, for noobs. It’s not intended to be some enterprise grade thing.

As always - review, make adjustments, and use at your own risk!

It downloads and installs the “latest” version of Duplicacy (i think that’s stable, right? Because it’s governed by what is on Duplicacy.com). And creates the systemd service (and prompts if you want to start/enable it). It can also do a force re-install if for some reason you want/need to.

With the help of ChatGPT, I created an installer based off his bash script. For what it’s worth, here 'tis :slight_smile:

I’ve only tested it on Linux Mint. Suggestions welcome.

use an editor of your choice and paste:

#!/bin/bash

# Function to prompt the user
prompt_install() {
    read -p "Duplicacy is not installed. Would you like to install it? (yes/no): " choice
    case "$choice" in
        y|Y|yes|Yes|YES ) install_duplicacy;;
        * ) echo "Installation aborted.";;
    esac
}

# Function to install Duplicacy
install_duplicacy() {
    echo "Identifying latest version from the website..."
    latest=$(curl -s "https://duplicacy.com/download.html" | grep -E -o "https://acrosync\.com/duplicacy-web/duplicacy_web_linux_x64_[[:digit:]]\.[[:digit:]]\.[[:digit:]]" | grep -E -o "duplicacy_web_linux_x64_[[:digit:]]\.[[:digit:]]\.[[:digit:]]")
    echo "Latest version is $latest"

    echo "Downloading latest version..."
    wget "https://acrosync.com/duplicacy-web/$latest" -P /tmp/

    if [ $? -ne 0 ]; then
        echo "Failed to download. Exiting."
        exit 1
    fi

    echo "Installing to /usr/bin/..."
    mv "/tmp/$latest" /usr/bin/
    chmod 700 "/usr/bin/$latest"
    ln -s -f "/usr/bin/$latest" /usr/bin/duplicacy-web

    echo "Creating systemd service file..."
    cat << EOF > /etc/systemd/system/duplicacy-web.service
[Unit]
Description=Duplicacy Web service
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/duplicacy-web

[Install]
WantedBy=default.target
EOF

    echo "Systemd service file created: /etc/systemd/system/duplicacy-web.service"

    read -p "Would you like to start and enable the duplicacy-web service? (yes/no): " choice
    case "$choice" in
        y|Y|yes|Yes|YES )
            echo "Starting and enabling the duplicacy-web service..."
            sudo systemctl daemon-reload
            sudo systemctl enable duplicacy-web
            sudo systemctl start duplicacy-web
            echo "Duplicacy-web service started and enabled."
            echo ""
            echo "press 'q' to exit status"
            echo ""
            systemctl status duplicacy-web
            ;;
        * )
            echo "Service was not started or enabled. You can start and enable it manually with:"
            echo "sudo systemctl daemon-reload"
            echo "sudo systemctl enable duplicacy-web"
            echo "sudo systemctl start duplicacy-web"
            ;;
    esac

    echo "Duplicacy successfully installed!"
    echo ""
    echo "WebUI running on: http://127.0.0.1:3875/"
    echo ""
    exit 0
}

# Check if Duplicacy is installed
if ! command -v duplicacy-web &> /dev/null; then
    prompt_install
else
    echo "Duplicacy is already installed."
    read -p "Would you like to force reinstall Duplicacy? (yes/no): " choice
    case "$choice" in
        y|Y|yes|Yes|YES ) install_duplicacy;;
        * ) echo "Reinstallation aborted.";;
    esac
fi

chmod +x duplicacyInstall.sh

then

sudo ./duplicacyInstall.sh

Should be good to go :slight_smile:

If you want to run it as user, instead of with sudo, change the script to put the systemd files in /home/[user]/.config/systemd/user (at least on my system that’s where they go). And also add --user to all the systemctl commands, e.g.: systemctl --user enable --now duplicacy-web.

I hope this helps the newbies :slight_smile:

And because i was experimenting so much, i whipped up a little duplicacyRemove.sh script too:

As always - review, make adjustments, and use at your own risk!

#!/bin/bash

echo "Stop and disable service..."
systemctl disable --now duplicacy-web.service
sleep 1
echo "Delete systemd file and reload systemd daemon..."
rm /etc/systemd/system/duplicacy-web.service
sudo systemctl daemon-reload
sleep 1
echo "Delete binary files..."
rm /usr/bin/duplicacy*
echo "Duplicacy successfully removed!"

And lastly - duplicacyUpdate.sh :slight_smile:

As always - review, make adjustments, and use at your own risk!

It will check the version installed, and update if a newer version is available. I might look to run this within my servers weeklystatusreport.sh which is timed to happen when backups are extremely unlikely to be happening. Or i might just set a reminder in my calendar to run it every now and then :slight_smile:

#!/bin/bash

# Identify latest version from the website
latest=$(curl -s "https://duplicacy.com/download.html" | grep -E -o "https://acrosync\.com/duplicacy-web/duplicacy_web_linux_x64_[[:digit:]]\.[[:digit:]]\.[[:digit:]]" | grep -E -o "duplicacy_web_linux_x64_[[:digit:]]\.[[:digit:]]\.[[:digit:]]")
echo "Latest version is $latest"

# Identify current installed version
current=$(ls -t /usr/bin/ | grep -m 1 -E -o "duplicacy_web_linux_x64_[[:digit:]]\.[[:digit:]]\.[[:digit:]]")
echo "Current version is $current"

# Compare versions
if [ "$current" != "$latest" ]; then
    echo "Update available"
    echo "Downloading new version..."
    
    # Download the new version
    wget "https://acrosync.com/duplicacy-web/$latest" -P /tmp/
    
    # Check if download succeeded
    if [ $? -ne 0 ]; then
        echo "Failed to download the new version. Exiting."
        exit 1
    fi
    
    # Stop the duplicacy-web service
    echo "Stopping duplicacy-web service..."
    systemctl stop duplicacy-web
    
    # Install the new version
    echo "Installing new version..."
    mv "/tmp/$latest" /usr/bin/
    chmod 700 "/usr/bin/$latest"
    
    # Update symbolic link
    ln -s -f "/usr/bin/$latest" /usr/bin/duplicacy-web
    
    # Remove old version
    if [ -n "$current" ]; then
        echo "Removing old version $current..."
        rm "/usr/bin/$current"
    fi

    # Start the duplicacy-web service
    echo "Restarting duplicacy-web service..."
    systemctl start duplicacy-web
    
    echo "Update complete!"
    echo ""
    echo "WebUI running on: http://127.0.0.1:3875/"
    echo ""
    exit 0
else
    echo "Latest version already installed."
fi

Also, per How to configure the Duplicacy Web Edition as a systemd service in Linux

If you’re using :d: web on a Linux PC with multiple users, you might want to:

sudo loginctl enable-linger <username>

To check the users were set up:

loginctl list-users or ls /var/lib/systemd/linger