Initial import - (formaly a SVN project named rcopy)
This commit is contained in:
59
hosts/scripts/net_mounted_dir_backup.sh
Executable file
59
hosts/scripts/net_mounted_dir_backup.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
## -
|
||||
## - If network directory have to mount (its only possible if backuping
|
||||
## - localhost) you need an entry in your /etc/fstab, becaus we mount thuch
|
||||
## - remote directories with "mount <remote directory)
|
||||
## -
|
||||
## - i.e. for a samba mounted directory you need an entry like:
|
||||
## -
|
||||
## - //192.168.100.20/qinter /mnt/file-win7/qinter smbfs noauto,user=Administrator,password=chnarzfoo5 0 0
|
||||
## -
|
||||
## - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
## - load functions
|
||||
## -
|
||||
. $rcopy_functions_file
|
||||
|
||||
if $mount_netdir ; then
|
||||
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
|
||||
echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet"
|
||||
exit 1
|
||||
else
|
||||
## - Network directory mounted ?
|
||||
## -
|
||||
if ! df | grep "$backup_dir" > /dev/null 2>&1 ;then
|
||||
$mount $backup_dir > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
|
||||
if ! df | grep "$backup_dir" > /dev/null 2>&1 ;then
|
||||
echolog "\t[ERROR] Cannot mount network directory to \"$backup_dir\""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
## - Check if directory is empty
|
||||
## -
|
||||
if [ ! "$(ls -A $backup_dir)" ]; then
|
||||
echolog "\t[ NOTICE ]: Directory \"$backup_dir\" is empty. So nothing to do..\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echolog "\n\tBackup network directory \"$backup_dir\" ( `$date +%H`:`$date +%M` h )"
|
||||
backup_dir=$backup_dir $script_dir/dir_backup.sh
|
||||
|
||||
if $mount_netdir ; then
|
||||
if [ $srcHost != "localhost" ];then
|
||||
echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet"
|
||||
exit 1
|
||||
else
|
||||
$umount $backup_dir 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user