Con questo articolo voglio ricollegarmi al problema già affrontato nell’uso del comando sudo. Il tutto è nato quando ho installato BackupPC su un server con Ubuntu 10.04 LTS (Lucid Lynx); praticamente il pacchetto di default va in errore durante la normale esecuzione di un backup in quanto alcuni file non sono leggibili dall’utente backuppc con cui gira l’applicazione che deve eseguire i backup. Quindi sono possibili due soluzioni; usare l’opzione –ignore-failed-read nell’esecuzione del comando tar (sconsigliato in quanto viene meno l’utilità del backup che salta proprio quei file importanti di sistema ad esempio in /etc) oppure editare il file sudoers in modo da autorizzare l’utente backuppc a eseguire il comando tar tramite sudo.

Qui sotto potete trovare il file di configurazione di BackupPC; da notare che ho commentato le righe errate del comando di esecuzione tar (sia la riga originale sia la riga con opzione –ignore-failed-read). Potete modificare il file direttamente con vi oppure usare l’interfaccia web di BackupPC.

alex@vegeta:/etc/backuppc$ sudo cat localhost.pl
#
# Local server backup of /etc as user backuppc
#
$Conf{XferMethod} = 'tar';

$Conf{TarShareName} = [
'/etc'
];

#$Conf{TarClientCmd} = '/usr/bin/env LC_ALL=C $tarPath -c -v -f - -C $shareName --totals';
#$Conf{TarClientCmd} = '/usr/bin/env LC_ALL=C $tarPath -c -v -f - -C $shareName --totals --ignore-failed-read';
$Conf{TarClientCmd} = '/usr/bin/sudo $tarPath -c -v -f - -C $shareName --totals';

Qui invece ho riportato una parte del file di configurazione /etc/sudoers in cui è presente la riga “backuppc ALL = NOPASSWD: /bin/tar” (ricordatevi di fare la modifica usando il comando visudo e di non editare direttamente il file con vi)

alex@vegeta:/etc/backuppc$ sudo cat /etc/sudoers
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
# User privilege specification
root    ALL=(ALL) ALL
backuppc ALL = NOPASSWD: /bin/tar

Una volta effettuate le modifiche possiamo controllare attraverso l’interfaccia web di BackupPC la corretta esecuzione del backup. Nelle due tabelle che seguono si nota che non sono più presenti degli errori nel backup e che le dimensione e il numero di file salvati è nettamente maggiore in quanto tutti i file vengono effettivamente salvati.

Xfer Error Summary
Backup# Type View #Xfer errs #bad files #bad share #tar errs
33 full XferLOG, Errors 179 0 0 0
34 incr XferLOG, Errors 126 0 0 0
35 full XferLOG, Errors 0 0 0 0

File Size/Count Reuse Summary

Existing files are those already in the pool; new files are those added to the pool. Empty files and SMB errors aren’t counted in the reuse and new counts.

Totals Existing Files New Files
Backup# Type #Files Size/MB MB/sec #Files Size/MB #Files Size/MB
33 full 2579 9.1 0.22 2578 9.1 2 0.0
34 incr 3 0.0 0.00 2 0.0 3 0.0
35 full 2971 28.2 1.76 2971 28.2 0 0.0
Contents of file /var/lib/backuppc/pc/localhost/LOG.062013, modified 2013-06-05 17:32:04

2013-06-05 17:25:26 full backup started for directory /etc
2013-06-05 17:25:53 Got fatal error during xfer (Tar exited with error 512 () status)
2013-06-05 17:25:58 Backup aborted (Tar exited with error 512 () status)
2013-06-05 17:30:55 full backup started for directory /etc
2013-06-05 17:31:10 full backup 39 complete, 3437 files, 0 bytes, 0 xferErrs (0 bad files, 0 bad shares, 0 other)

Link utili:

https://bugs.launchpad.net/ubuntu/+source/backuppc/+bug/497732

http://backuppc.sourceforge.net/faq/localhost.html

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.