Folder backup automation to server location

Hi there,

Im struggling with below if someone can help :smiley:

I would like to create an automatic script that runs each night at a designated time to back up files from a specific local folder to a folder on a server,

I have attempted to automate this using automater and I have had some success so far but I have encountered a problem with it. Basically if the server is already connected it throws back an error after it attempts to connect to the server again and does not proceed with the next steps. I was wondering if it would be easier to do this process in a script.

it would need to do the following

  1. Copy files from specific folder on local machine.
  2. Connect to specific server location. If server is already connected then ignore this step.
  3. Paste files from local machine to a specific folder on the server.

I understand I can use automater to run this script via a calendar event but would need some assistance with the scripting,

Any help would be hugely appreciated.

Many thanks.

Try this


set networkDrive to "YourNetworkDriveShareName" as string
set theDrives to list disks
if theDrives does not contain networkDrive then
-- replace the text in quotes with the server address from the Connect to Server window 
	mount volume "smb://servername.yourcompany.com/YourNetworkDriveShareName"
end if


set folderName to "/path/to/source/folder" as string
set destinationName to "/Volumes/YourNetworkDriveShareName/path/to/folder" as string

set copyScript to "cp " & quoted form of folderName & " " & quoted form of destinationName as string
do shell script copyScript