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

    #!/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


 



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
screen
re-attach a detached session tmux attach OR
tmux attach-session
screen-r
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]
  • Make ISO from DVD

    In this case I had an OS install disk which was required to be on a virtual node with no optical drive, so I needed to transfer an image to the server to create a VM

    Find out which device the DVD is:

    lsblk

    Output:

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 464.8G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-swap 253:1 0 11.8G 0 lvm [SWAP] └─centos-home 253:2 0 403G 0 lvm /home sdb 8:16 1 14.5G 0 disk /mnt sr0 11:0 1 4.1G 0 rom /run/media/rick/CCSA_X64FRE_EN-US_DV5

    Therefore /dev/sr0 is the location , or disk to be made into an ISO

    I prefer simplicity, and sometimes deal with the fallout after the fact, however Ive repeated this countless times with success.

    dd if=/dev/sr0 of=win10.iso

    Where if=Input file and of=output file

    I chill out and do something else while the image is being copied/created, and the final output:

    8555456+0 records in 8555456+0 records out 4380393472 bytes (4.4 GB) copied, 331.937 s, 13.2 MB/s

    Fin!

    read more
  • Recreate postrgresql database template encode to ASCII

    UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';

    Now we can drop it:

    DROP DATABASE template1;

    Create database from template0, with a new default encoding:

    CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; \c template1 VACUUM FREEZE;

    read more
});