How to create a batch file on Mac?
I need to find a solution at work to back up certain folders daily, hopefully to a RAR or ZIP file.
If it was on a PC, I would have done it already. But I don't know how to approach it on Mac.
What I basically want to achieve is an automated task that can be started with an executable that does the following:
compress specific directory (
) into rar or zip file.
(the zip file excludes all * .wav files in all subdirectories and the names of the "Video" directories).
move it to a network share (
/Volumes/Post Shared/Backup From Sound
(or compress directly into this folder).
automate zip file name with dynamic date and time (so no duplicate file names).
Shutting down the Mac when finished.
I want to reiterate that I usually don't use a Mac, so things like the file that opens for the script and stuff that isn't trivial for me yet.
I tried to put Mark bash lines (from the first answer below) in a txt file and executed it, but it had errors and didn't work.
I also tried to use Automator, but it's too simple, no additional parameters.
How can i do this?
I would love a working example :)
source to share
You can just make a
script that does the backup and then you can either double click it or run it on schedule. I don't know your paths and / or selection tools, but something along these lines:
"/Volumes/path/to/network/share/Backup/%Y-%m-%d.tgz"` cd /directory/to/backup || exit 1 tar -cvz "$FILENAME" .FILENAME=`date +
You can save this to your desktop as
and then go to Terminal and type:
chmod +x ~/Desktop/backup
to make it executable. Then you can simply double-click on it - obviously after changing the paths to reflect what you want to do and where.
Also, you can use some other tools like
, but the method is the same.
source to share