Package: samba Version: 2:3.2.5-4lenny6 Followup-For: Bug #473651 On Wed, 16 Apr 2008 23:08:20 -0700, Steve Langasek <vor...@debian.org> wrote: > Actually yes, I do object because I don't think we should be doing piecemeal > backups in individual packages. Losing winbind_idmap is bad, but not worse > than losing other databases on the system, and I haven't seen that tdbs are > noticeably more fragile than other database formats that they should require > a separate backup policy from the rest of the system.
I just spent an hour modifying and testing the pre-existing /etc/cron.daily/samba to backup the /var/lib/samba/*.tdb files to /var/backups/samba on a number of Samba servers that I manage. If /etc/samba/smbpasswd is important enough to backup, then so is secrets.tdb, winbind_idmap.tdb, and all of the others. My goal in the attached script is to provide a reasonable chance of recovery in case /var/lib/samba gets blown away. Use it if you like, ignore it if you don't. One other point: many well-meaning sysadmins may be doing rsync backups of their entire systems, including /var/lib/samba, thinking that they are safe in case of any catastrophe. But they might not be aware that the modification date on the *.tdb files rarely gets changed, even if the contents do, because Samba uses mmap() to access them. As a result, rsync might pick up the *.tdb files the first time they are seen and then never again. At least by running tdbbackup regularly, one can guarantee that rsynced *.tdb.bak files are somewhat up-to-date. Personally I do not see anything wrong in supplying a minimal backup procedure as part of a package. Perhaps it should not be installed into /etc/cron* by default, but that is another subject.
#!/bin/sh # # cron script to save a backup copy of /etc/samba/smbpasswd in /var/backups. # # Written by Eloy A. Paris <pe...@debian.org> for the Debian project. # Augmented by Erik Rossen <ros...@rossen.ch> to backup *.tdb files. # BAK=/var/backups/samba umask 022 mkdir -p $BAK if cd $BAK; then # Make sure /etc/samba/smbpasswd exists if [ -f /etc/samba/smbpasswd ]; then cmp -s smbpasswd.bak /etc/samba/smbpasswd || cp -p /etc/samba/smbpasswd smbpasswd.bak fi # Make sure tdbbackup exists if [ -x /usr/bin/tdbbackup ]; then /usr/bin/tdbbackup /var/lib/samba/*.tdb for i in /var/lib/samba/*.tdb.bak ; do j=$(basename $i) cmp -s $j $i || cp -p $i $j done fi fi