Hello, possibly the author of the samba backup script will read this. I customized the script myself due to some things: 1. At the end the script looks for samba4_* files to rotate the backups. But only backups of the private folder get this prefix with the original script. sysvol and etc backups will remain. 2. The wiki of backup and restore advises to restore on the same version of samba the backup was made of. So it makes sense to get samba version into the backup names. A variable like $(samba -V) could do this? 3. Possibly it's more compatible with the most distributions to use tar.gz. My CentOS 7 produces errors with tar.bz2 without additional packages. I will post my samba backup script when I'm back at work. Regards Tim
rintimtim at gmx.net
2015-Jan-12 16:23 UTC
[Samba] Thoughts on samba backup script for DCs
I forgot to mention: 4. DAYS-Variable is not used at the end of the script for rotating the backups I have to say that I use Sernet-packages so that I don't have a etc-folder in /var/lib/samba I copy the needed files to a custom created etc-folder. Here is my script: #### Begin Script #### #!/bin/sh # # Copyright (C) Matthieu Patou <mat at matws.net> 2010-2011 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # FROMWHERE=/var/lib/samba WHERE=/var/lib/samba/backup #SAMBAVER=$(samba -V | cut -d' ' -f2) SAMBAVER=$(samba -V | sed s/\ /_/) \cp -R /etc/samba/ $FROMWHERE/etc/ \cp -R /etc/default/ $FROMWHERE/etc/ if [ -n "$1" ] && [ "$1" = "-h" -o "$1" = "--usage" ]; then echo "samba_backup [provisiondir] [destinationdir]" echo "Will backup your provision located in provisiondir to archive stored in destinationdir" echo "Default provisiondir: $FROMWHERE" echo "Default destinationdir: $WHERE" exit 0 fi [ -n "$1" -a -d "$1" ]&&FROMWHERE=$1 [ -n "$2" -a -d "$2" ]&&WHERE=$2 DIRS="private etc sysvol" #Number of days to keep the backup DAYS=90 WHEN=`date +%d%m%Y%H%M` if [ ! -d $WHERE ]; then echo "Missing backup directory $WHERE" exit 1 fi if [ ! -d $FROMWHERE ]; then echo "Missing or wrong provision directory $FROMWHERE" exit 1 fi cd $FROMWHERE for d in $DIRS;do # relativedirname=`find . -type d -name "$d" -prune` relativedirname="./$d" n=`echo $d | sed 's/\//_/g'` if [ "$d" = "private" ]; then find $relativedirname -name "*.ldb.bak" -exec rm {} \; for ldb in `find $relativedirname -name "*.ldb"`; do tdbbackup $ldb if [ $? -ne 0 ]; then echo "Error while backuping $ldb" exit 1 fi done tar -czf ${WHERE}/samba4_${n}.${SAMBAVER}.${WHEN}.tar.gz $relativedirname --exclude=*.ldb >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "Error while archiving ${WHERE}/samba4_${n}.${SAMBAVER}.${WHEN}.tar.gz" exit 1 fi find $relativedirname -name "*.ldb.bak" -exec rm {} \; else tar -czf ${WHERE}/samba4_${n}.${SAMBAVER}.${WHEN}.tar.gz $relativedirname >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "Error while archiving ${WHERE}/samba4_${n}.${SAMBAVER}.${WHEN}.tar.gz" exit 1 fi fi done find $WHERE -name "samba4_*gz" -mtime +$DAYS -exec rm {} \; >/dev/null 2>&1 #### End Script #### Regards Tim ? Gesendet:?Sonntag, 11. Januar 2015 um 11:52 Uhr Von:?Tim <rintimtim at gmx.net> An:?samba at lists.samba.org Betreff:?[Samba] Thoughts on samba backup script for DCs Hello, possibly the author of the samba backup script will read this. I customized the script myself due to some things: 1. At the end the script looks for samba4_* files to rotate the backups. But only backups of the private folder get this prefix with the original script. sysvol and etc backups will remain. 2. The wiki of backup and restore advises to restore on the same version of samba the backup was made of. So it makes sense to get samba version into the backup names. A variable like $(samba -V) could do this? 3. Possibly it's more compatible with the most distributions to use tar.gz. My CentOS 7 produces errors with tar.bz2 without additional packages. I will post my samba backup script when I'm back at work. Regards Tim -- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/options/samba