Backup di client Windows con BackupPC

From RVM Wiki
Revision as of 15:59, 27 February 2012 by Gabriele.vivinetto (talk | contribs)
Jump to navigation Jump to search

Configurazione Client

  • 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
  • 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
ssh 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 
  • 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
  • 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

  • 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

Configurazione per 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';

Configurazione per Server

  • Creare il file di configurazione del server:
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',
];

# 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} = '$sshPath -q -x -l Administrator $hostIP /usr/local/bin/post-backup.sh';

#$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';

Riferimenti