Backup di client Windows con BackupPC
Jump to navigation
Jump to search
Configurazione Client da backuppare
- Installare cygwin con
binutils openssh rsync screen unzip util-linux vim wget zip
- Impostare Environment Variables
- Right click My Computer, Properties, Advanced, Environment Variables, System Variables
- Aggiungere:
CYGWIN = ntsec
- Modificare il PATH aggiungendo
;c:\cygwin\bin
- Make sure every Windows user has a password set (System Preference / User Accounts) and Make sure every Windows user has done the following at least once (this will create home directories for every user):
- Configurare ssh come Administrator, aprendo un cygwin terminal in locale:
ssh-host-config --yes --cygwin ntsec
- Se lo si fa invece manualmente, rispondere si a tutte le domande, e settare quando richiesto
CYGWIN = ntsec
- If you get an error message (Windows XP)
- >> ERROR: Problem with /var directory. Exiting.
- >> Change permissions:
chmod 775 /var
- Se non ci si riesce a loggare, e l'utente Windows usato per il servizio è di dominio, bisogna aggiungergli la policy locale di Create token object:
gpedit.msc local computer policy\computer configuration\windows settings\security settings\local policies\user rights assignment look for 'create a token object' add DOMAINNAME\cyg_server user
- Start ssh with:
net start sshd
- Synchronize User-Accounts with Cygwin. Login as Administrator, start a Cygwin Shell:
mkpasswd -cl > /etc/passwd mkgroup --local > /etc/group
- Creare le directory di ssh (a volte è necessario forzare lo username con la "A" maiuscola):
ssh Administrator@localhost
- Disabilitare il firewall
Client scripts
- Installare i programmi:
cd wget -O backuppc-shadow.zip http://support.rvmgroup.it/download/backuppc-shadow.zip cd /usr/local/bin unzip -ox ~/backuppc-shadow.zip && rm -f ~/backuppc-shadow.zip cp vshadow-CYGWIN_NT-5.2.exe vshadow-CYGWIN_NT-5.2-WOW64.exe
- Sistemare le permission
chgrp Administrators /usr/local/bin/* chmod 755 /usr/local/bin/*
- Modificare i DISCHI da shadoware:
vi /usr/local/bin/pre-backup.sh
- Creare il file di configurazione:
vi /etc/backuppc-shadow
DRIVES="c d e" ACL=true SHADOW=true
- Create a file /etc/rsyncd.conf on your client:
vi /etc/rsyncd.conf
gid = users read only = true use chroot = false transfer logging = false log file = /var/log/rsyncd.log log format = %h %o %f %l %b hosts allow = 192.168.0.0/16 hosts deny = 0.0.0.0/0 strict modes = false [root] path = /cygdrive/ auth users = Administrator secrets file = /etc/rsyncd.secret
- Make sure to replace with the correct values for your setup:
host allow auth users
- Creare il file
vi /etc/rsyncd.secret
Administrator:PASSWORD
Configurazione Server BackupPc
- Copiare la chiave di backuppc sul client
sudo -u backuppc ssh-copy-id Administrator@myclient
- Verificare se si accede:
sudo -u backuppc ssh Administrator@myclient
File di configurazione per backup Pc Desktop
- Creare il file di configurazione del client:
sudoedit /etc/backuppc/myclient.pl
#
# Rsync over ssh Backup
#
$Conf{BackupsDisable} = 0;
$Conf{WakeupSchedule} = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
# Minimum period in days between full and incremental backups:
# 1 Full alla settimana
$Conf{FullPeriod} = 6.97;
# almeno un incr al giorno
$Conf{IncrPeriod} = 0.49;
# Number of full and incremental backups to keep:
$Conf{FullKeepCnt} = 12;
$Conf{IncrKeepCnt} = 63;
# Note that additional fulls will be kept for as long as is necessary
# to support remaining incrementals.
# What transport to use backup the client [smb|rsync|rsyncd|tar|archive]:
$Conf{XferMethod} = 'rsync';
# The file system path or the name of the rsyncd module to backup when
# using rsync/rsyncd:
$Conf{RsyncShareName} = [
'/cygdrive/c',
'/cygdrive/d',
];
# If this is defined only these files/paths will be included in the backup:
#$Conf{BackupFilesOnly} = undef;
# These files/paths will be excluded from the backup:
$Conf{BackupFilesExclude} = {
#Windows 7/Vista specific!
'*' => [
#7/Vista junction points
'/Documents and Settings',
'/ProgramData/Application Data',
'/ProgramData/Desktop',
'/ProgramData/Documents',
'/ProgramData/Favorites',
'/ProgramData/Start Menu',
'/ProgramData/Templates',
'/Users/All Users',
'/Users/Users/Default User',
'/Users/Users/All Users/Application Data',
'/Users/Users/All Users/Desktop',
'/Users/All Users/Documents',
'/Users/All Users/Favorites',
'/Users/All Users/Start Menu',
'/Users/All Users/Templates',
#Junction points common to every user profile
'/Users/*/Application Data',
'/Users/*/Cookies',
'/Users/*/Local Settings',
'/Users/*/My Documents',
'/Users/*/NetHood',
'/Users/*/PrintHood',
'/Users/*/Recent',
'/Users/*/SendTo',
'/Users/*/Start Menu',
'/Users/*/Templates',
'/Users/*/AppData/Local/Application Data',
'/Users/*/AppData/Local/History',
'/Users/*/AppData/Local/Temporary Internet Files',
'/Users/*/Documents/My Music',
'/Users/*/Documents/My Pictures',
'/Users/*/Documents/My Videos',
#Temporary and in-use user data
'/Users/*/AppData/Local/Microsoft/Windows/Temporary Internet Files',
'/Users/*/AppData/Local/Temp',
'/Users/*/NTUSER.DAT*',
'/Users/*/ntuser.dat*',
'/Users/*/AppData/Local/Microsoft/Windows/UsrClass.dat*',
'/Users/*/AppData/Local/Microsoft/Windows Defender/FileTracker',
'/Users/*/AppData/Local/Microsoft/Windows/Explorer/thumbcache_*.db',
'/Users/*/AppData/Local/Microsoft/Windows/WER',
'/Users/*/AppData/Local/Mozilla/Firefox/Profiles/*/Cache',
'/Users/*/AppData/Local/Mozilla/Firefox/Profiles/*/OfflineCache',
'/Users/*/AppData/Roaming/Microsoft/Windows/Cookies',
'/Users/*/AppData/Roaming/Microsoft/Windows/Recent',
'ProgramData/Microsoft/Search',
'ProgramData/Microsoft/Windows Defender',
'*.lock',
'Thumbs.db',
'IconCache.db',
'Cache*',
'cache*',
#Installation folders and system data
'/Program Files',
'/Windows',
'/$Recycle.Bin',
'/MSOCache',
'/System Volume Information',
'/Boot',
'/autoexec.bat',
'/bootmgr',
'/BOOTSECT.BAK',
'/config.sys',
'/hiberfil.sys',
'/pagefile.sys'
]
};
# Level of verbosity in Xfer log files:
$Conf{XferLogLevel} = 1;
# Commands to run for client backups:
# Note the use of SSH's -C attribute. This enables compression in SSH.
#$Conf{RsyncClientCmd} = '$sshPath -C -x -l administrator -o PreferredAuthentications=publickey $host $rsyncPath $argList+';
# Commands to run for client direct restores:
# Note the use of SSH's -C attribute. This enables compression in SSH.
#$Conf{RsyncClientRestoreCmd} = '$sshPath -C -q -x -l administrator $host $rsyncPath $argList+';
# Compression level to use on files. 0 means no compression. See notes
# in main config file before changing after backups have already been done.
$Conf{CompressLevel} = 9;
# The backup may occur over vpn. Avoid "ping too slow" errors.
$Conf{PingMaxMsec} = 150;
# Timeout if backing up large files ?
$Conf{ClientTimeout} = 3600*8; # 6 Hours!!
$Conf{RsyncClientCmd} = '$sshPath -q -x -l Administrator $host $rsyncPath $argList+';
$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l Administrator $host $rsyncPath $argList+';
$Conf{DumpPreUserCmd} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/shadowmountrsync -u 1 -A 1';
$Conf{DumpPostUserCmd} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/shadowmountrsync -d';
File di Configurazione per backup Pc Server
- Creare il file di configurazione del server. In questo caso lo script a termine lavoro disattiva la vss e richiama poi lo script di notifica:
sudoedit /etc/backuppc/myclient.pl
#
# Rsync over ssh Backup
#
$Conf{BackupsDisable} = 1;
# Minimum period in days between full and incremental backups:
# 1 Full alla settimana
$Conf{FullPeriod} = 6.97;
# almeno un incr al giorno
$Conf{IncrPeriod} = 0.49;
# Number of full and incremental backups to keep:
$Conf{FullKeepCnt} = 12;
$Conf{IncrKeepCnt} = 63;
# Note that additional fulls will be kept for as long as is necessary
# to support remaining incrementals.
# What transport to use backup the client [smb|rsync|rsyncd|tar|archive]:
$Conf{XferMethod} = 'rsync';
# The file system path or the name of the rsyncd module to backup when
# using rsync/rsyncd:
$Conf{RsyncShareName} = [
'/cygdrive/c/shadow/c/cygwin/bin',
'/cygdrive/c/shadow/d/tmp',
];
# If this is defined only these files/paths will be included in the backup:
#$Conf{BackupFilesOnly} = undef;
# These files/paths will be excluded from the backup:
$Conf{BackupFilesExclude} = {
#Windows 7/Vista specific!
'*' => [
#7/Vista junction points
'/Documents and Settings',
'/ProgramData/Application Data',
'/ProgramData/Desktop',
'/ProgramData/Documents',
'/ProgramData/Favorites',
'/ProgramData/Start Menu',
'/ProgramData/Templates',
'/Users/All Users',
'/Users/Users/Default User',
'/Users/Users/All Users/Application Data',
'/Users/Users/All Users/Desktop',
'/Users/All Users/Documents',
'/Users/All Users/Favorites',
'/Users/All Users/Start Menu',
'/Users/All Users/Templates',
#Junction points common to every user profile
'/Users/*/Application Data',
'/Users/*/Cookies',
'/Users/*/Local Settings',
'/Users/*/My Documents',
'/Users/*/NetHood',
'/Users/*/PrintHood',
'/Users/*/Recent',
'/Users/*/SendTo',
'/Users/*/Start Menu',
'/Users/*/Templates',
'/Users/*/AppData/Local/Application Data',
'/Users/*/AppData/Local/History',
'/Users/*/AppData/Local/Temporary Internet Files',
'/Users/*/Documents/My Music',
'/Users/*/Documents/My Pictures',
'/Users/*/Documents/My Videos',
#Temporary and in-use user data
#'/Users/*/AppData/Local/Microsoft/Windows/Temporary Internet Files',
#'/Users/*/AppData/Local/Temp',
#'/Users/*/NTUSER.DAT*',
#'/Users/*/ntuser.dat*',
#'/Users/*/AppData/Local/Microsoft/Windows/UsrClass.dat*',
#'/Users/*/AppData/Local/Microsoft/Windows Defender/FileTracker',
#'/Users/*/AppData/Local/Microsoft/Windows/Explorer/thumbcache_*.db',
#'/Users/*/AppData/Local/Microsoft/Windows/WER',
#'/Users/*/AppData/Local/Mozilla/Firefox/Profiles/*/Cache',
#'/Users/*/AppData/Local/Mozilla/Firefox/Profiles/*/OfflineCache',
#'/Users/*/AppData/Roaming/Microsoft/Windows/Cookies',
#'/Users/*/AppData/Roaming/Microsoft/Windows/Recent',
#'ProgramData/Microsoft/Search',
#'ProgramData/Microsoft/Windows Defender',
#'*.lock',
#'Thumbs.db',
#'IconCache.db',
#'Cache*',
#'cache*',
#Installation folders and system data
#'/Program Files',
#'/Windows',
#'/$Recycle.Bin',
#'/MSOCache',
#'/System Volume Information',
#'/Boot',
#'/autoexec.bat',
#'/bootmgr',
#'/BOOTSECT.BAK',
#'/config.sys',
'c/hiberfil.sys',
'c/pagefile.sys',
'd/hiberfil.sys',
'd/pagefile.sys',
'e/hiberfil.sys',
'e/pagefile.sys',
]
};
# Level of verbosity in Xfer log files:
$Conf{XferLogLevel} = 1;
# Commands to run for client backups:
# Note the use of SSH's -C attribute. This enables compression in SSH.
#$Conf{RsyncClientCmd} = '$sshPath -C -x -l administrator -o PreferredAuthentications=publickey $host $rsyncPath $argList+';
# Commands to run for client direct restores:
# Note the use of SSH's -C attribute. This enables compression in SSH.
#$Conf{RsyncClientRestoreCmd} = '$sshPath -C -q -x -l administrator $host $rsyncPath $argList+';
# Compression level to use on files. 0 means no compression. See notes
# in main config file before changing after backups have already been done.
$Conf{CompressLevel} = 9;
# The backup may occur over vpn. Avoid "ping too slow" errors.
$Conf{PingMaxMsec} = 150;
# Timeout if backing up large files ?
$Conf{ClientTimeout} = 3600*8; # 6 Hours!!
$Conf{RsyncClientCmd} = '$sshPath -q -x -l Administrator $host $rsyncPath $argList+';
$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l Administrator $host $rsyncPath $argList+';
$Conf{DumpPreUserCmd} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/pre-backup.sh';
$Conf{DumpPostUserCmd} = '/usr/local/bin/BackupPC_DumpPostUserCmd.vss $type $xferOK $client $host $hostIP $user $moreUsers $XferMethod $sshPath $cmdType';
#$Conf{DumpPreUserCmd} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/shadowmountrsync -u 1 -A 1';
#$Conf{DumpPostUserCmd} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/shadowmountrsync -d';
Configurazione del Job di backup
- Sistemare le permission del file di configurazione:
sudo chown backuppc:www-data /etc/backuppc/myclient.pl
- Creare lo script post job:
sudoedit /usr/local/bin/BackupPC_DumpPostUserCmd.vss
#!/bin/bash
# 2013022801
# Script server per lanciare post-backup
#
#
set -x
type="$1"
xferOK="$2"
client="$3"
host="$4"
hostIP="$5"
user="$6"
moreUsers="$7"
share="$8"
shares="$9"
XferMethod="${10}"
sshPath="${11}"
cmdType="${12}"
cat <<EOFile
Parameters are:
type=$1
xferOK=$2
client=$3
host=$4
hostIP=$5
user=$6
moreUsers=$7
share=$8
shares=$9
XferMethod=${10}
sshPath=${11}
cmdType=${12}
sshUser=${13}
EOFile
if [ -n $sshUser ]
then
sshUser="Administrator"
fi
$sshPath -q -x -l $sshUser $hostIP /usr/local/bin/post-backup.sh
/usr/local/bin/BackupPC_DumpPostUserCmd $@
- Renderlo eseguibile:
sudo chmod +x /usr/local/bin/BackupPC_DumpPostUserCmd.vss
- Assicurarsi che ci sia lo script di notifica esito backup:
sudoedit /usr/local/bin/BackupPC_DumpPostUserCmd
#!/bin/bash
# 2013022801
# /usr/local/bin/BackupPC_DumpPostUserCmd
# Script di notifica esito backup
#
set -x
type="$1"
xferOK="$2"
client="$3"
host="$4"
hostIP="$5"
user="$6"
moreUsers="$7"
XferMethod="$8"
sshPath="$9"
cmdType=${10}
user="${11}"
$sshPath -q -x -l root $hostIP /usr/local/bin/post-backup.sh
if [ $xferOK -eq 1 ]
then
SUBJECT="Backup Succesful of $client"
MSG=$(cat <<EOFile
The backup of $client was succesfull.
Parameters are:
type=$1
xferOK=$2
client=$3
host=$4
hostIP=$5
user=$6
moreUsers=$7
share=$8
shares=$9
XferMethod=${10}
sshPath=${11}
cmdType=${12}
EOFile
)
else
SUBJECT="Backup UNSUCCESSFUL of $client"
MSG=$(cat <<EOFile
The backup of $client was UNSUCCESFUL.
Parameters are:
type=$1
xferOK=$2
client=$3
host=$4
hostIP=$5
user=$6
moreUsers=$7
share=$8
shares=$9
XferMethod=${10}
sshPath=${11}
cmdType=${12}
EOFile
)
fi
echo -e $MSG
echo -e $MSG | mail -s "${SUBJECT}" $moreUsers
- Renderlo eseguibile:
sudo chmod +x /usr/local/bin/BackupPC_DumpPostUserCmd
- Inserire l'host nella configurazione di backuppc:
sudoedit /etc/backuppc/hosts
myclient 0 backuppc, email@example.com
- Riavviare backuppc:
sudo invoke-rc.d backuppc restart
- Testare il backup
sudo -u backuppc /usr/share/backuppc/bin/BackupPC_dump -v -f myclient
Schedulazione del Backup
- Verificare che backuppc poss ainviare correttamente email:
sudo -u backuppc /usr/share/backuppc/bin/BackupPC_sendEmail -u recipient@example.com
- Creare il file crontab, che
- Testa se backuppc è attivo
- Fa un backup incrementale da Lun a Ven alle 23:00
- Fa un backup completo il Sabato alle 23:00
sudoedit /etc/cron.d/backuppc
# # Regular cron jobs for backuppc # #min hours DayOfMonth Month DayOfWeek user command # Check if backuppc is running. If not, send a warning email 00 * * * * backuppc /usr/share/backuppc/bin/BackupPC_sendEmail -c > /dev/null # Incr backup mon-fri 00 23 * * 1-5 backuppc /usr/local/sbin/BackupPcBackup 0 > /dev/null # Full backup sat 00 23 * * 6 backuppc /usr/local/sbin/BackupPcBackup 1 > /dev/null
- Creare lo script per l'esecuzione dei backup
sudoedit /usr/local/sbin/BackupPcBackup
#!/bin/bash TYPE=$1 # TYPE=0 Incremental # TYPE=1 Full /usr/share/backuppc/bin/BackupPC_serverMesg backup myclientip myclientname backuppc $TYPE #/usr/share/backuppc/bin/BackupPC_serverMesg backup 5.6.7.8 myclient2 backuppc $TYPE
- Rendere eseguibile:
sudo chmod +x /usr/local/sbin/BackupPcBackup
- Testare il submit del job manualmente:
sudo -u backuppc /usr/share/backuppc/bin/BackupPC_serverMesg backup myclientip myclientname backuppc 1
- Testare il submit del job del backup completo:
sudo -u backuppc /usr/local/sbin/BackupPcBackup 1
Riferimenti
- BackupPC with ssh/rsync/VSS on Windows Server « majentis technologies
- Optimal backups for Windows machines
- vshadow.exe versions // blog.edgylogic
- Ufficiale sito backuppc:
- Client backuppcd (sembra non mantenuto):
- BackupPC Install Guide for Windows 7/Vista/XP Clients & Ubuntu Server
- Utilizza VSS: SourceForge.net: User Scripts - Client - Windows VSS - backuppc
- HowTos/BackupPC - CentOS Wiki
- BackupPC with ssh/rsync/VSS on Windows Server « Gerald Brandt
- BackupPC Install Guide for Windows 7/Vista/XP Clients
- Backup Central Forums :: View topic - Complete cygwin/VSS/rsync solution for Windows Backup
- Backup Central Forums :: View topic - Fwd: Complete cygwin/VSS/rsync solution for Windows Backup
- Backing Up Open Files on Windows with Rsync (and BackupPC) | Good Job Sucking
- Download: SubInACL (SubInACL.exe) - Microsoft Download Center - Download Details