Outils pour utilisateurs

Outils du site


kb:linux:donnees:backup_avec_backuppc

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
kb:linux:donnees:backup_avec_backuppc [2019/06/17 22:04] beukb:linux:donnees:backup_avec_backuppc [2020/01/24 08:21] (Version actuelle) beu
Ligne 94: Ligne 94:
 #!/bin/bash #!/bin/bash
  
-if [ -z "$1" ];then 
- echo -e "usage : ./backuppc4-setup.sh --install (or upgrade from backuppc 3)\nor: ./backuppc4-setup.sh --upgrade\nMUST BE RUN AS ROOT" 
- exit 1 
-fi 
 if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root"     echo "This script must be run as root" 
Ligne 103: Ligne 99:
 fi fi
  
-case $1 in  +echo -e "CAREFUL !\nIf you're installing from backuppc 3, backups and hosts will (normally) be conserved, \nBUT some configuration need to be changed manually by you (Apache2, backup settings,...).\nBackup your /etc/backuppc directory, and Good luck !" 
-        --install) +read -n 1 -s -r -p "Press any key to continue" 
-                echo -e "CAREFUL !\nIf you're installing from backuppc 3, backups and hosts will (normally) be conserved, \nBUT some configuration need to be changed manually by you (Apache2, backup settings,...).\nBackup your /etc/backuppc directory, and Good luck !" +echo "PURGE DE BACKUPPC ET AJOUT DES DÉPENDENCES" 
-                read -n 1 -s -r -p "Press any key to continue" +apt remove backuppc 
-                echo "PURGE DE BACKUPPC ET AJOUT DES DÉPENDENCES" +apt-get install -y par acl  libacl1-dev apache2 apache2-utils libapache2-mod-perl2 glusterfs-client par2 perl smbclient rsync tar gcc zlib1g zlib1g-dev libapache2-mod-scgi rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libtime-parsedate-perl
-                apt remove backuppc +
-                apt-get install -y par acl  libacl1-dev 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+
  
-                if [ ! -d "/var/lib/backuppc" ]; then +if [ ! -d "/var/lib/backuppc" ]; then 
-                        mkdir /var/lib/backuppc +        mkdir /var/lib/backuppc 
-                        echo "CREATION DE L'UTILISATEUR BACKUPPC" +        echo "CREATION DE L'UTILISATEUR BACKUPPC" 
-                        adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/bash backuppc +        adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/bash backuppc 
-                        mkdir -p /var/lib/backuppc/.ssh +        mkdir -p /var/lib/backuppc/.ssh 
-                        ssh-keygen -q -t rsa -b 4096 -N '' -C "BackupPC key" -f /var/lib/backuppc/.ssh/id_rsa +        ssh-keygen -q -t rsa -b 4096 -N '' -C "BackupPC key" -f /var/lib/backuppc/.ssh/id_rsa 
-                        echo -e "BatchMode yes" > /var/lib/backuppc/.ssh/config +        echo -e "BatchMode yes\nStrictHostKeyChecking accept-new" > /var/lib/backuppc/.ssh/config 
-                        chmod 700 /var/lib/backuppc/.ssh && chmod 600 /var/lib/backuppc/.ssh/id_rsa && chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub && chmod 644 /var/lib/backuppc/.ssh/config && chown -R backuppc:backuppc /var/lib/backuppc/.ssh  +        chmod 700 /var/lib/backuppc/.ssh && chmod 600 /var/lib/backuppc/.ssh/id_rsa && chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub && chmod 644 /var/lib/backuppc/.ssh/config && chown -R backuppc:backuppc /var/lib/backuppc/.ssh  
-                fi+fi
  
-                mkdir /opt/backuppc-build-env +pushd `mktemp -d` 
-                pushd /opt/backuppc-build-env+mkdir backuppc rsync-bpc backuppc-xs
  
-                echo "RECUPERATION DES DÉPOTS BACKUPPC" +echo "RECUPERATION DES DÉPOTS BACKUPPC" 
-                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+curl -s https://api.github.com/repos/backuppc/backuppc/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O backuppc.tar.gz 
 +curl -s https://api.github.com/repos/backuppc/rsync-bpc/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O rsync-bpc.tar.gz 
 +curl -s https://api.github.com/repos/backuppc/backuppc-xs/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O backuppc-xs.tar.gz
  
-                echo "COMPILATION DE BACKUPPC-XS" +echo "COMPILATION DE BACKUPPC-XS" 
-                cd backuppc-xs +tar -xzf backuppc-xs.tar.gz -C backuppc-xs/ 
-                git tag | tail -1 | xargs git checkout +cd backuppc-xs/*/ 
-                perl Makefile.PL +perl Makefile.PL 
-                make +make 
-                make test +make test 
-                make install+make install 
 +cd ../../
  
-                echo "COMPILATION DE RSYNC-BPC" +echo "COMPILATION DE RSYNC-BPC" 
-                cd ../rsync-bpc +tar -xzf rsync-bpc.tar.gz -C rsync-bpc/ 
-                git tag | tail -1 | xargs git checkout +cd rsync-bpc/*/ 
-                ./configure +./configure 
-                make +make 
-                make install+make install 
 +cd ../../
  
-                echo "COMPILATION DE BACKUPPC" +echo "COMPILATION DE BACKUPPC" 
-                cd ../backuppc +tar -xzf backuppc.tar.gz -C backuppc/ 
-                git tag | tail -1 | xargs git checkout +cd backuppc/*/ 
-                ./makeDist --nosyntaxCheck --releasedate "`date -u "+%d %b %Y"`" --version git +if [ -f "/etc/backuppc/config.pl" ]; then 
-                tar -zxf dist/BackupPC-git.tar.gz + systemctl stop backuppc 
-                cd BackupPC-${bpcver}git +        ./configure.pl --batch --config-path /etc/backuppc/config.pl 
-                if [ -f "/etc/backuppc/config.pl" ]; then + popd 
-                        ./configure.pl --batch --config-path /etc/backuppc/config.pl + systemctl start backuppc 
-                else +else 
-                        ./configure.pl --batch --cgi-dir /usr/local/backuppc/cgi-bin --data-dir /var/lib/backuppc --hostname backuppc --html-dir /usr/local/backuppc/cgi-bin --html-dir-url '' --install-dir /usr/local/backuppc --config-dir /etc/backuppc +        ./configure.pl --batch --cgi-dir /usr/local/backuppc/cgi-bin --data-dir /var/lib/backuppc --hostname backuppc --html-dir /usr/local/backuppc/cgi-bin --html-dir-url '' --install-dir /usr/local/backuppc --config-dir /etc/backuppc 
-                fi+ echo "CONFIGURATION DE BACKUPPC" 
 + cp systemd/backuppc.service /etc/systemd/system/ && systemctl daemon-reload 
 + sed -i "s/{CgiAdminUsers}     = '';/{CgiAdminUsers}     = 'backuppc';/g" /etc/backuppc/config.pl 
 + systemctl enable --now backuppc
  
-                echo "CONFIGURATION DE BACKUPPC" + echo "CONFIGURATION D'APACHE2" 
-                cp systemd/backuppc.service /etc/systemd/system/ && systemctl daemon-reload + cat << EOF > /etc/apache2/sites-available/001-backuppc.conf
-                systemctl enable backuppc && systemctl start backuppc +
- +
-                echo "CONFIGURATION D'APACHE2" +
-                cat << EOF > /etc/apache2/sites-available/001-backuppc.conf+
 <VirtualHost *:80> <VirtualHost *:80>
         DocumentRoot /usr/local/backuppc/cgi-bin         DocumentRoot /usr/local/backuppc/cgi-bin
Ligne 184: Ligne 181:
  
 EOF EOF
-                sed -i 's/www-data/backuppc/' /etc/apache2/envvars + sed -i 's/www-data/backuppc/' /etc/apache2/envvars 
-                a2dissite * + a2dissite 000-default 
-                a2enmod cgid && a2ensite 001-backuppc.conf+ a2enmod cgid && a2ensite 001-backuppc.conf
  
-                systemctl restart apache2+ systemctl restart apache2
  
-                if [ ! -f "/etc/backuppc/htpasswd" ]; then + if [ ! -f "/etc/backuppc/htpasswd" ]; then 
-                        touch /etc/backuppc/htpasswd +         touch /etc/backuppc/htpasswd 
-                        htpasswd -b /etc/backuppc/htpasswd 'admin' 'backuppc+         htpasswd -b /etc/backuppc/htpasswd 'backuppc' 'password
-                fi + fi
- +
-                popd +
-        ;; +
-        --upgrade) +
-                systemctl stop backuppc +
-                if [ ! -d "/opt/backuppc-build-env" ]; then +
-                        mkdir /opt/backuppc-build-env +
-                fi +
-                pushd /opt/backuppc-build-env +
- +
-                echo "COMPILATION ET MISE A JOUR DE BACKUPPC-XS" +
-                if [ -d "backuppc-xs" ]; then +
-                        cd backuppc-xs +
-                        git pull +
-                else +
-                        git clone https://github.com/backuppc/backuppc-xs.git +
-                        cd backuppc-xs +
- +
-                fi +
-                git tag | tail -1 | xargs git checkout +
-                perl Makefile.PL +
-                make +
-                make test +
-                make install +
-                cd .. +
- +
-                echo "COMPILATION ET MISE A JOUR DE RSYNC-BPC" +
-                if [ -d "rsync-bpc" ]; then +
-                        cd rsync-bpc +
-                        git pull +
-                else +
-                        git clone https://github.com/backuppc/rsync-bpc.git +
-                        cd rsync-bpc +
- +
-                fi +
-                git tag | tail -1 | xargs git checkout +
-                ./configure +
-                make +
-                make install +
-                cd .. +
- +
-                echo "COMPILATION ET MISE A JOUR DE BACKUPPC" +
-                if [ -d "backuppc" ]; then +
-                        cd backuppc +
-                        git pull +
-                else +
-                        git clone https://github.com/backuppc/backuppc.git +
-                        cd backuppc +
- +
-                fi +
-                git tag | tail -1 | xargs git checkout +
-                ./configure.pl --batch --config-path /etc/backuppc/config.pl +
-                popd +
-                systemctl start backuppc +
- +
-        ;; +
-        *) +
-                echo -e "usage : ./backuppc-setup4.sh --install (or upgrade from backuppc 3)\nor: ./backuppc4-setup.sh --upgrade"  +
-                exit 1 +
-                ;; +
-esac+
  
 + popd
 +fi
  
-echo "FINI !"+echo -e "FINI !\nUse the account backuppc with the password 'password'"
 </code> </code>
  
  
kb/linux/donnees/backup_avec_backuppc.1560809059.txt.gz · Dernière modification : 2019/06/17 22:04 de beu