I found this backup script in the forums and am using it to backup the office 2011 Database file. The script is not working. It seems as if the Casper Programming Argument of $3 is not passing through the user name. Any ideas would help.
#!/bin/bash
afp_server=""
afp_volume="backups"
AFP_Monitor_User=""
AFP_Monitor_PSWD="*"
if ! [ -d "/Volumes/$afp_volume" ] ; then
# Assume they do not have this volume mounted
mkdir "/Volumes/$afp_volume" ;
mount_afp "afp://$AFP_Monitor_User:$AFP_Monitor_PSWD@$afp_server/$afp_volume" "/Volumes/$afp_volume"
else
# They have a volume of the same name mounted [on some server]
# I would test for proper file rights here
touch "/Volumes/$afp_volume/Backups"
if [ -e "/Volumes/$afp_volume/Backups" ] ; then
true
# User can write here
else
false
# User can't write here
fi
fi
# create the users folder we are going to move. Casper uses $3 for the logged in user when running scripts.
# set a variable so we don't have to retype it a lot.
UsersCustomPath="/Volumes/$afp_volume/Backups/$3"
# use -p to create any needed sub directories
mkdir -p "$UsersCustomPath"
# Now let's do the copy.
# man says use -p to preserve the following attributes of each source file
# in the copy: modification time, access time, file flags, file mode,
# user ID, and group ID, as allowed by permissions. Access Control
# Lists (ACLs) and Extended Attributes (EAs), including resource
# forks, will also be preserved.
#
# There is more but you probably won't run into it... consult 'man cp' if you want to know more.
#
# we also likely want sub directories: use -R
#
# if you want to follow symbolic links add -L
# if you want each copy to show in the log use verbose mode: -v
cp -pRv "/Users/$3/Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Database" "UsersCustomPath"
Error I get:
Script Result: cp: /Users//Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Database: No such file or directory