Install BackupPC4 Ubuntu Debian {script}

  • 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).

    set -e
    # 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
    if [[ $PASSWORD == "" ]]; then
      apt-get -qq -y install pwgen
      PASSWORD=`pwgen -s -1 32`
      echo "Generated password: $PASSWORD"
      echo "Password given is: $PASSWORD"
    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/
    chown -R backuppc:backuppc /var/lib/backuppc/.ssh
    # Fetch and install latest stable releases
    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 test
    make install
    cd ../rsync-bpc-$rsyncbpcver
    make install
    cd ../BackupPC-$bpcver
    # To fetch and install the latest development code instead, replace the above section with:
    #git clone
    #git clone
    #git clone
    #cd backuppc-xs
    #perl Makefile.PL
    #make test
    #make install
    #cd ../rsync-bpc
    #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
    ./ --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:
    # ./ --batch --config-path /etc/BackupPC/
    # 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/
    sed -i "s/$Conf{CgiAdminUsers}.*/$Conf{CgiAdminUsers} = 'backuppc';/" /etc/BackupPC/
    chown -R backuppc:backuppc /etc/BackupPC
    # Needed only when installing
    echo $PASSWORD | htpasswd -i /etc/BackupPC/BackupPC.users backuppc
    service backuppc start

  • Use the same script for updating/ upgrading

    Make sure to change the versions to the latest releases:

    set -e

    Scroll through the script, know what you are doing.

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

Tmux Commands

screen and tmux

A comparison of the features (or more-so just a table of notes for accessing some of those features) for GNU screen and BSD-licensed tmux.

The formatting here is simple enough to understand (I would hope). ^ means ctrl+, so ^x is ctrl+x. M- means meta (generally left-alt or escape)+, so M-x is left-alt+x

It should be noted that this is no where near a full feature-set of either group. This - being a cheat-sheet - is just to point out the most very basic features to get you on the road.

Trust the developers and manpage writers more than me. This document is originally from 2009 when tmux was still new - since then both of these programs have had many updates and features added (not all of which have been dutifully noted here).

Action tmux screen
start a new session tmux OR
tmux new OR
tmux new-session
re-attach a detached session tmux attach OR
tmux attach-session
re-attach an attached session (detaching it from elsewhere) tmux attach -d OR
tmux attach-session -d
screen -dr
re-attach an attached session (keeping it attached elsewhere) tmux attach OR
tmux attach-session
screen -x
detach from currently attached session ^b d OR
^b :detach
^a ^d OR
^a :detach
rename-window to newname ^b , <newname> OR
^b :rename-window <newn>
^a A <newname>
list windows ^b w ^a w
list windows in chooseable menu ^a "
go to window # ^b # ^a #
go to last-active window ^b l ^a ^a
go to next window ^b n ^a n
go to previous window ^b p ^a p
see keybindings ^b ? ^a ?
list sessions ^b s OR
tmux ls OR
tmux list-sessions
screen -ls
toggle visual bell ^a ^g
create another window ^b c ^a c
exit current shell/window ^d ^d
split window/pane horizontally ^b " ^a S
split window/pane vertically ^b % ^a |
switch to other pane ^b o ^a <tab>
kill the current pane ^b x OR (logout/^D)
collapse the current pane/split (but leave processes running) ^a X
cycle location of panes ^b ^o
swap current pane with previous ^b {
swap current pane with next ^b }
show time ^b t
show numeric values of panes ^b q
toggle zoom-state of current pane (maximize/return current pane) ^b z
break the current pane out of its window (to form new window) ^b !
re-arrange current panels within same window (different layouts) ^b [space]
Kill the current window (and all panes within) ^b killw [target-window]
  • 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=

    Scroll through the script, know what you are doing.

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

    read more
  • Again running smartctl after all is said and done:

    smartctl --all /dev/sda

    ddrescue-smartctl-after-rescue.png ddrescue-smartctl-2.png

    Yet an old drive in itself, I run the wheels off of them, and monitor regularly as anyone should.

    read more