I want to back up more than 2tb of data, my largest drive is 2tb. To do this I’ll need to have some things backup to one drive and other things backup to another.
I have 2 problems that I can’t figure out how to deal with.
- setting up as a cron job to run every half hour.
- setting it up so it can run unattended. Right now it asks for username and password to change plist filenames.
The script so far. It works but it requires my input to work.
-- current TimMachine plist
set d0 to "com.apple.TimeMachine.plist"
-- media files TimeMachine plist
set d1 to "com.apple.TimeMachine.disk1.plist"
-- system and user TimeMachine plist
set d2 to "com.apple.TimeMachine.disk2.plist"
-- path to TimeMachine plists
property pth : "Macintosh HD:Library:Preferences:"
-- turn off TimeMachine so filenames can be changed
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool false"
tell application "Finder"
-- test if TimeMachine plist exits. It will cause all kinds of trouble if it isn't and runs creating a blank profile
-- eg; file d0 is copied to d1 but d2 is not copied to d0 because pw was input wrong second time
if (exists file d0 of the folder pth) then
-- test which file is currently being used as backup and change to other one
if (exists file d1 of the folder pth) then
set the name of file d0 in folder pth to d2
set the name of file d1 in folder pth to d0
else
set the name of file d0 in folder pth to d1
set the name of file d2 in folder pth to d0
end if
else
set the name of file d1 in folder pth to d0
end if
end tell
-- run the backup
do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
-- turn TimeMachine auto backup back on just in case
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool true"
=======
Any help would be appreciated
Thank you.
Browser: Safari 535.19
Operating System: Mac OS X (10.7)
A discussion about an incompatibility between CronniX and Lion suggests that using cron may be a bad idea on the long run.
(https://code.google.com/p/cronnix/issues/detail?id=12)
The intended way to launch jobs periodically is launchd which is configured using property lists.
Configuration files for system wide background jobs are in /Library/LaunchDaemons. These should not ask for any user name and password. But I never tried if there are problems using an AppleScript that again calls userland applications like the Finder.
The simple way to find out the syntax for a plist: Get Lingon and use it to create one.
About a year ago I wrote an AppleScript creating plists for periodic jobs:
http://www.j-schell.de/node/323
Hope it works that way.
Jürgen
Thank you for the info it helped.
I’ve got the scheduling issue dealt with.
But the script is still demanding username and password of an admin account to run.
I am stymied as to how to get around this so it can run unattended.
I am also curious of applescript has something to do branch control like switch case.
Hi,
of course you have to enter username and password, because you don’t own the files you’re dealing with.
Using the shell you can do things with admin or root privileges for example
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool false"user name "username" password "password" with administrator privileges
The Finder doesn’t provide such an option, so you would have to do the renaming part also with the shell
Unfortunately no
This is the part that is demanding an admin username and password.
It asks for a username and password for each change of name.
I’ve run disk utility and repair disk permissions no problems found there. I have no idea how to get the names to change without asking for password.
I’ve updated the script a bit and it looks so ugly to me. And the branch control is giving me a headache.
I’m also not sure if I setup try properly.
-- current TimMachine plist
set d0 to "com.apple.TimeMachine.plist"
-- media files TimeMachine plist
set d1 to "com.apple.TimeMachine.disk1.plist"
-- system and user TimeMachine plist
set d2 to "com.apple.TimeMachine.disk2.plist"
-- path to TimeMachine plists
property pth : "Macintosh HD:Library:Preferences:"
-- turn off TimeMachine so filenames can be changed
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool false"
tell application "Finder"
-- test if file d0, d1 and d2 exists
if (exists file d0 of the folder pth) then
if (exists file d1 of the folder pth) then
if (exists file d2 of the folder pth) then
-- all 3 files exists which means an error has happened and was not caught
-- running the script again could mean losing one of the backup plists
display alert "Too many plist files"
else if (exists file d1 of the folder pth) then
-- file d0 and d1 exist changing to d1 as backup settings
set the name of document file d0 in folder pth to d2
set the name of document file d1 in folder pth to d0
-- run the backup
do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
-- turn TimeMachine auto backup back on just in case
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool true"
end if
else
-- file d0 exists but not d1 changing to d2 as backup settings
try
set the name of document file d0 in folder pth to d1
set the name of document file d2 in folder pth to d0
-- run the backup
do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
-- turn TimeMachine auto backup back on just in case
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool true"
on error errMsg
display dialog "Missing d2 plist"
end try
end if
else
-- file d0 is missing copying d1 to d0 and running backup
try
set the name of document file d1 in folder pth to d0
-- run the backup
do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
-- turn TimeMachine auto backup back on just in case
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool true"
on error errMsg
display dialog "Missing d1 plist"
end try
end if
end tell
The problem with asking for password to change the filenames still exists so it can not run unattended still
If there is an easier way to do this or one that isn’t so messy, please please please tell me.
Thanks
Tom
As I mentioned in post #4 the Finder can’t write into a dictionary outside your home folder without being asked for the password for security reasons.
The shell command mv can rename files, in AppleScript with the do shell script command
do shell script "mv /path/to/originalName /path/to/newName" user name "username" password "password" with administrator privileges
Thank you all for your help.
I have it working now.
Tom