It took a bit more work than I expected to get BackupPC_deleteBackup working
on FreeBSD.  And, not being able to edit the wiki page, I'm throwing my diffs
out on here in case they might be useful to other people.
------------------------------------------------------------------------------

--- BackupPC_deleteBackup.orig  2012-09-13 14:40:47.686108699 -0500
+++ BackupPC_deleteBackup       2012-09-13 15:56:02.052710796 -0500
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /usr/local/bin/bash
 #
 #this script contributed by Matthias Meyer
 #note that if your $Topdir seems to be wrong (because it is empty), the script 
will ask you
@@ -13,6 +13,9 @@
 #10/2010 MMT: Modified by Matthias Meyer
 #      check /etc/backuppc as well as /etc/BackupPC
 #
+#09/2012 LKC: Modified by Lawrence Chen
+#      make it work on FreeBSD 9.0
+#
 usage="\
 Usage: $0 [-c <client> [-d <backupnumber> -b <before data> -r [-f]] | [-l]] | 
[-n]
 
@@ -48,7 +51,7 @@
 function run_BackupPC_nightly ()
 {
        path=${0%/BackupPC*}
-       if [ ! -e $path/BackupPC_serverMesg ]; then 
path="/usr/share/BackupPC/bin"; fi
+       if [ ! -e $path/BackupPC_serverMesg ]; then path="/usr/local/bin"; fi
        echo "Running BackupPC_nightly..."
        $path/BackupPC_serverMesg BackupPC_nightly run
        $path/BackupPC_serverMesg log I honestly apologize for the inconvenience
@@ -57,7 +60,7 @@
 
 #JJK: NOTE NFS shares may only be accessible by 'backuppc' (not even by root 
if not 'no_root_squash') so run as user 'backuppc'
 [ "`id -un`" != "backuppc" -a "`id -un`" != "root" ] && echo "Must be either 
'root' or 'backuppc' to run" && exit
-[ "`id -un`" != "backuppc" ] && exec su backuppc -s /bin/bash -c "$0 $*"
+[ "`id -un`" != "backuppc" ] && exec su backuppc -c /usr/local/bin/bash -c "$0 
$*"
 
 while test $# -gt 0; do
        case "$1" in
@@ -91,14 +94,14 @@
 #read -p "not tested yet. Do you want to continue anyway [Y/N]? " answer
 #if [ "$answer" != "Y" ] && [ "$answer" != "y" ]; then exit 1; fi
 
-if [ -e /etc/backuppc/config.pl ]; then configDir="/etc/backuppc"
-elif [ -e /etc/BackupPC/config.pl ]; then configDir="/etc/BackupPC"
+if [ -e /usr/local/etc/backuppc/config.pl ]; then 
configDir="/usr/local/etc/backuppc"
+elif [ -e /usr/local/etc/BackupPC/config.pl ]; then 
configDir="/usr/local/etc/BackupPC"
 else
        echo "BackupPCs config.pl not found"
        exit 1
 fi
 
-TopDir=`grep $Conf{TopDir} $configDir/config.pl | awk '{print $3}'`
+TopDir=`grep '^\$Conf{TopDir}' $configDir/config.pl | awk '{print $3}'`
 len=${#TopDir}-3
 TopDir=${TopDir:1:len}
 
@@ -109,7 +112,7 @@
        ls $TopDir/pc > /dev/null 2>&1
 done
 
-LogDir=`grep $Conf{LogDir} $configDir/config.pl | awk '{print $3}'`
+LogDir=`grep '^\$Conf{LogDir}' $configDir/config.pl | awk '{print $3}'`
 len=${#LogDir}-3
 LogDir=${LogDir:1:len}
 if [ ! -e $LogDir/LOG ]; then LogDir="$TopDir/log"; fi
@@ -130,8 +133,8 @@
                        echo "$CLine" >> $configDir/hosts.new
                fi
        done < $configDir/hosts
-       chown --reference=$configDir/hosts $configDir/hosts.new
-       chmod --reference=$configDir/hosts $configDir/hosts.new
+       chown backuppc:backuppc $configDir/hosts.new
+       chmod 640 $configDir/hosts.new
        mv $configDir/hosts.new $configDir/hosts > /dev/null 2>&1
        rm -f $configDir/$client.pl* > /dev/null 2>&1
 fi
@@ -149,7 +152,7 @@
        do
                BackupNumber=`echo $CLine | awk '{print $1}'`
                BackupType=`echo $CLine | awk '{print $2}'`
-               BackupTime=`stat -c "%y" 
$TopDir/pc/$client/$BackupNumber/backupInfo | awk '{print $1}'`
+               BackupTime=`stat -f "%Sm" -t "%Y-%m-%d" 
$TopDir/pc/$client/$BackupNumber/backupInfo`
                echo "BackupNumber $BackupNumber - $BackupType-Backup from 
$BackupTime"
        done < $TopDir/pc/$client/backups
        exit 0
@@ -169,7 +172,7 @@
        while read CLine
        do
                BackupNumber=`echo $CLine | awk '{print $1}'`
-               BackupTime=`stat -c "%y" 
$TopDir/pc/$client/$BackupNumber/backupInfo | awk '{print $1}'`
+               BackupTime=`stat -f "%Sm" -t "%Y-%m-%d" 
$TopDir/pc/$client/$BackupNumber/backupInfo`
                BackupType=`echo $CLine | awk '{print $2}'`
                if [ $BackupType == "full" ]
                then
@@ -199,8 +202,8 @@
                        echo "$CLine" >> $TopDir/pc/$client/backups.new
                fi
        done < $TopDir/pc/$client/backups
-       chown --reference=$TopDir/pc/$client/backups 
$TopDir/pc/$client/backups.new > /dev/null 2>&1
-       chmod --reference=$TopDir/pc/$client/backups 
$TopDir/pc/$client/backups.new > /dev/null 2>&1
+       chown backuppc:backuppc $TopDir/pc/$client/backups.new > /dev/null 2>&1
+       chmod 640 $TopDir/pc/$client/backups.new > /dev/null 2>&1
        mv $TopDir/pc/$client/backups.new $TopDir/pc/$client/backups > 
/dev/null 2>&1
        echo "`date +\"%Y-%m-%d %T\"` BackupPC_deleteBackup 
$TopDir/pc/$client/backups updated" >> $LogDir/LOG
 elif [ ! -z $entire ]

------------------------------------------------------------------------------
Enjoy! 8-)

-- 
  Name: Lawrence "The Dreamer" Chen        Email: [email protected]
 Snail: 1530 College Ave, A5                 URL: http://www.lhaven.net
        Manhattan, KS 66502-2768
  Blog: http://lawrencechen.net            Phone: 785-789-4132

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BackupPC-users mailing list
[email protected]
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

Reply via email to