Skip to content

Su backuppc backuppc4

Backup Solutions

FreeBSD Notes
  • New script due to dependency changes:

    #! /bin/sh set -e

    if [ “$1” = “install” ] || [ “$1” = “upgrade” ]; then

    ACTION=$1

    elif [ “$1” = “” ]; then ACTION=install else echo “usage: $(basename $0) action [source]” echo “action is either install (default) or upgrade” echo “source is either tar (default) or git” exit 1 fi

    if [ “$2” = “git” ] || [ “$2” = “tar” ]; then SOURCE=$2 elif [ “$2” = “” ]; then SOURCE=tar else echo “Unknown source $2!” exit 1 fi

    if [ “$BPC_UID” ] && [ $(getent passwd “$BPC_UID” | cut -d ‘:’ -f 1) != “backuppc” ]; then echo “The uid = $BPC_UID is already in use!” exit 1 fi

    #Install dependencies

    apt-get -q update export DEBIAN_FRONTEND=noninteractive apt-get install -q -y apache2 apache2-utils libapache2-mod-perl2 par2 perl smbclient rsync tar gcc zlib1g zlib1g-dev rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libacl1-dev wget iputils-ping pwgen

    #Set up backuppc user and directory

    if ! id backuppc >/dev/null 2>&1; then if [ “$BPC_UID” ]; then adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false --uid=“$BPC_UID” backuppc else adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false backuppc fi fi mkdir -p /var/lib/backuppc/.ssh chmod 700 /var/lib/backuppc/.ssh echo -e “BatchMode yes\nStrictHostKeyChecking no” > /var/lib/backuppc/.ssh/config if [ ! -e /var/lib/backuppc/.ssh/id_rsa ]; then ssh-keygen -q -t rsa -b 4096 -N ‘’ -C “BackupPC key” -f /var/lib/backuppc/.ssh/id_rsa fi chmod 600 /var/lib/backuppc/.ssh/id_rsa chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub chown -R backuppc:backuppc /var/lib/backuppc/.ssh

    #Set password or read password file

    if [ “$BPC_PASS” ]; then PASSWORD=“$BPC_PASS” elif [ -e /root/password ]; then PASSWORD=$(cat /root/password) chmod 600 /root/password else PASSWORD=$(pwgen -s -1 32) echo “$PASSWORD” > /root/password chmod 600 /root/password fi echo “backuppc:$PASSWORD” | chpasswd backuppc

    #Get BackupPC release versions

    get_latest_release() { wget -q -O - “https://api.github.com/repos/$1/releases/latest” | grep ‘“tag_name”:’ | sed -E ‘s/.“([^”]+)"./\1/’
    } bpcver=$(get_latest_release “backuppc/backuppc”) bpcxsver=$(get_latest_release “backuppc/backuppc-xs”) rsyncbpcver=$(get_latest_release “backuppc/rsync-bpc”)

    mkdir -p /tmp/bpc cd /tmp/bpc

    if [ $SOURCE = “tar” ]; then

    ##Fetch and install latest stable releases

    wget https://github.com/backuppc/backuppc-xs/releases/download/$bpcxsver/BackupPC-XS-$bpcxsver.tar.gz wget https://github.com/backuppc/rsync-bpc/releases/download/$rsyncbpcver/rsync-bpc-$rsyncbpcver.tar.gz wget https://github.com/backuppc/backuppc/releases/download/$bpcver/BackupPC-$bpcver.tar.gz tar -zxf BackupPC-XS-$bpcxsver.tar.gz tar -zxf rsync-bpc-$rsyncbpcver.tar.gz tar -zxf BackupPC-$bpcver.tar.gz cd BackupPC-XS-$bpcxsver perl Makefile.PL make make test make install cd …/rsync-bpc-$rsyncbpcver ./configure make make install cd …/BackupPC-$bpcver fi

    if [ $SOURCE = “git” ]; then

    #Fetch and install the latest development code instead

    git clone https://github.com/backuppc/backuppc.git git clone https://github.com/backuppc/backuppc-xs.git git clone https://github.com/backuppc/rsync-bpc.git cd backuppc-xs perl Makefile.PL make make test make install cd …/rsync-bpc ./configure make make install cd …/backuppc ./makeDist --nosyntaxCheck --releasedate “date -u "+%d %b %Y"” --version ${bpcver}git tar -zxf dist/BackupPC-${bpcver}git.tar.gz cd BackupPC-${bpcver}git fi

    if [ $ACTION = “install” ]; then ./configure.pl --batch --cgi-dir /var/www/cgi-bin/BackupPC --data-dir /var/lib/backuppc --hostname backuppc --html-dir /var/www/html/BackupPC --html-dir-url /BackupPC --install-dir /usr/local/BackupPC fi

    if [ $ACTION = “upgrade” ]; then ./configure.pl --batch --config-path /etc/BackupPC/config.pl fi

    #Set up web server #Note that changing the apache user and group (/etc/apache2/envvars) could cause other services #provided by apache to fail. There are alternatives if you don’t want to change the apache #user: use SCGI or a setuid BackupPC_Admin script - see the docs. cp httpd/BackupPC.conf /etc/apache2/conf-available/backuppc.conf sed -i “/Require local/d” /etc/apache2/conf-available/backuppc.conf sed -i “s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=backuppc/” /etc/apache2/envvars sed -i “s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=backuppc/” /etc/apache2/envvars echo ‘’ > /var/www/html/index.html a2enconf backuppc a2enmod cgid service apache2 restart

    #Set up backuppc service

    cp systemd/init.d/debian-backuppc /etc/init.d/backuppc

    chmod 755 /etc/init.d/backuppc

    update-rc.d backuppc defaults

    chmod u-s /var/www/cgi-bin/BackupPC/BackupPC_Admin

    touch /etc/BackupPC/BackupPC.users

    sed -i “s/$Conf{CgiAdminUserGroup}.*/$Conf{CgiAdminUserGroup} = ‘backuppc’;/” /etc/BackupPC/config.pl

    sed -i “s/$Conf{CgiAdminUsers}.*/$Conf{CgiAdminUsers} = ‘backuppc’;/” /etc/BackupPC/config.pl

    chown -R backuppc:backuppc /etc/BackupPC

    echo $PASSWORD | htpasswd -i /etc/BackupPC/BackupPC.users backuppc

    service backuppc start

    #Clean up

    cd rm -rf /tmp/bpc echo “All done!” exit 0

    read more

  • Use the same script for updating/ upgrading

    Make sure to change the versions to the latest releases:

    #!/bin/bash set -e bpcver=4.2.1 bpcxsver=0.57 rsyncbpcver=3.0.9.12

    Scroll through the script, know what you are doing.

    Uncomment the upgrade section(s) and comment out the install section(s)

    read more

  • Install BackupPC4 Debian Ubuntu

    The following page outlines how to install BackupPC 4 from the latest official release tarballs or from git. For instructions on building packages, see Build Your Own Packages.

    These instructions are tested on Ubuntu Xenial 16.04 LTS and Ubuntu Bionic 18.04 LTS. The script will likely work on other versions and on most other Debian-derived distributions as well.

    Installing BackupPC 4 from the latest git sources is a rather long process at the moment. To make it easy, you can use the following script to install a dedicated BackupPC 4 server. The script is tested on a clean installation, so beware of any conflicting web sites if you are not installing on a dedicated server.

    The script will use a single password for both your web interface backuppc user and the local backuppc user. It also allows any client to connect, so make sure to tune security settings for a production environment. Run it with root privileges (i.e. sudo bash installbackuppc or chmod 755 installbackuppc && sudo ./installbackuppc if you saved the script as installbackuppc).

    IMPORTANT SCRIPT UPDATE: Latest script updated

    #!/bin/bash set -e bpcver=4.2.1 bpcxsver=0.57 rsyncbpcver=3.0.9.12 # Needed only when installing apt-get install -q -y apache2 apache2-utils libapache2-mod-perl2 glusterfs-client par2 perl smbclient rsync tar sendmail gcc zlib1g zlib1g-dev libapache2-mod-scgi rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl echo -n "Give password or leave empty to generate one: " read -s PASSWORD echo if [[ $PASSWORD == "" ]]; then apt-get -qq -y install pwgen PASSWORD=`pwgen -s -1 32` echo "Generated password: $PASSWORD" else echo "Password given is: $PASSWORD" fi echo "$PASSWORD" > /root/password chmod 600 /root/password mkdir /srv/backuppc ln -s /srv/backuppc/ /var/lib/backuppc adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false backuppc echo "backuppc:$PASSWORD" | sudo chpasswd backuppc mkdir -p /var/lib/backuppc/.ssh chmod 700 /var/lib/backuppc/.ssh echo -e "BatchMode yes\nStrictHostKeyChecking no" > /var/lib/backuppc/.ssh/config ssh-keygen -q -t rsa -b 4096 -N '' -C "BackupPC key" -f /var/lib/backuppc/.ssh/id_rsa chmod 600 /var/lib/backuppc/.ssh/id_rsa chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub chown -R backuppc:backuppc /var/lib/backuppc/.ssh # Fetch and install latest stable releases wget https://github.com/backuppc/backuppc-xs/releases/download/$bpcxsver/BackupPC-XS-$bpcxsver.tar.gz wget https://github.com/backuppc/rsync-bpc/releases/download/$rsyncbpcver/rsync-bpc-$rsyncbpcver.tar.gz wget https://github.com/backuppc/backuppc/releases/download/$bpcver/BackupPC-$bpcver.tar.gz tar -zxf BackupPC-XS-$bpcxsver.tar.gz tar -zxf rsync-bpc-$rsyncbpcver.tar.gz tar -zxf BackupPC-$bpcver.tar.gz cd BackupPC-XS-$bpcxsver perl Makefile.PL make make test make install cd ../rsync-bpc-$rsyncbpcver ./configure make make install cd ../BackupPC-$bpcver # To fetch and install the latest development code instead, replace the above section with: #git clone https://github.com/backuppc/backuppc.git #git clone https://github.com/backuppc/backuppc-xs.git #git clone https://github.com/backuppc/rsync-bpc.git #cd backuppc-xs #perl Makefile.PL #make #make test #make install #cd ../rsync-bpc #./configure #make #make install #cd ../backuppc #./makeDist --nosyntaxCheck --releasedate "`date -u "+%d %b %Y"`" --version ${bpcver}git #tar -zxf dist/BackupPC-${bpcver}git.tar.gz #cd BackupPC-${bpcver}git # When installing, use this ./configure.pl --batch --cgi-dir /var/www/cgi-bin/BackupPC --data-dir /var/lib/backuppc --hostname backuppc --html-dir /var/www/html/BackupPC --html-dir-url /BackupPC --install-dir /usr/local/BackupPC # When upgrading, use this instead: # ./configure.pl --batch --config-path /etc/BackupPC/config.pl # The following is good also when upgrading, unless you have modified the files yourself cp httpd/BackupPC.conf /etc/apache2/conf-available/backuppc.conf sed -i "/deny\ from\ all/d" /etc/apache2/conf-available/backuppc.conf sed -i "/deny\,allow/d" /etc/apache2/conf-available/backuppc.conf sed -i "/allow\ from/d" /etc/apache2/conf-available/backuppc.conf # Note that changing the apache user and group (next two commands) could cause other services # provided by apache to fail. There are alternatives if you don't want to change the apache # user: use SCGI or a setuid BackupPC_Admin script - see the docs. sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=backuppc/" /etc/apache2/envvars sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=backuppc/" /etc/apache2/envvars echo '<html><head><meta http-equiv="refresh" content="0; url=/BackupPC_Admin"></head></html>' > /var/www/html/index.html a2enconf backuppc a2enmod cgid service apache2 restart cp systemd/init.d/debian-backuppc /etc/init.d/backuppc chmod 755 /etc/init.d/backuppc update-rc.d backuppc defaults chmod u-s /var/www/cgi-bin/BackupPC/BackupPC_Admin touch /etc/BackupPC/BackupPC.users sed -i "s/$Conf{CgiAdminUserGroup}.*/$Conf{CgiAdminUserGroup} = 'backuppc';/" /etc/BackupPC/config.pl sed -i "s/$Conf{CgiAdminUsers}.*/$Conf{CgiAdminUsers} = 'backuppc';/" /etc/BackupPC/config.pl chown -R backuppc:backuppc /etc/BackupPC # Needed only when installing echo $PASSWORD | htpasswd -i /etc/BackupPC/BackupPC.users backuppc service backuppc start

    https://github.com/backuppc/backuppc/wiki/Installing-BackupPC-4-from-tarball-or-git-on-Ubuntu

    read more

  • Having trouble getting to the backuppc user to ssh-copy-id ?

    su -s /bin/bash - backuppc

    or

    sudo su -s /bin/bash - backuppc

    read more