4

I need to find a solution at work to backup specific folders daily, hopefully to a RAR or ZIP file.

If it was on PC, I would have done it already. But I don't have any idea to how to approach it on a Mac.

What I basically want to achieve is an automated task, that can be run with an executable, that does:

  1. compress a specific directory (/Volumes/Audio/Shoko) to a rar or zip file.

    (in the zip file exclude all *.wav files in all sub Directories and a directory names "Videos").

  2. move It to a network share (/Volumes/Post Shared/Backup From Sound).

    (or compress directly to this folder).

  3. automate the file name of the Zip file with dynamic date and time (so no duplicate file names).

  4. Shutdown Mac when finished.

I want to say again, I don't usually use Mac, so things like what kind of file to open for the script, and stuff like that is not trivial for me, yet.

I have tried to put Mark's 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 plain, no advanced options.

How can I accomplish this?

I would love a working example :)

Thank You,

Dave

David Gidony
  • 1,243
  • 3
  • 16
  • 31

1 Answers1

7

You can just make a bash script that does the backup and then you can either double-click it or run it on a schedule. I don't know your paths and/or tools of choice, but some thing along these lines:

#!/bin/bash
FILENAME=`date +"/Volumes/path/to/network/share/Backup/%Y-%m-%d.tgz"`
cd /directory/to/backup || exit 1
tar -cvz "$FILENAME" .

You can save that on your Desktop as backup and then go in Terminal and type:

chmod +x ~/Desktop/backup

to make it executable. Then you can just double click on it - obviously after changing the paths to reflect what you want to backup and where to.

Also, you may prefer to use some other tools - such as rsync but the method is the same.

tripleee
  • 175,061
  • 34
  • 275
  • 318
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Hi mark, I hadn't had the chance to try it yet, rest assure that once I will , I will update/mark as an answer – David Gidony Oct 19 '14 at 10:54
  • im not sure I know how to do it . am I suppose to just create a new text file with the text editor, or what ? its not going to well :) – David Gidony Oct 19 '14 at 16:28
  • 1
    You can't save it as RTF, it needs to be plain text. – tripleee Oct 20 '14 at 15:05
  • 1
    +1 This should work once you figure out how to save as a proper text file. – tripleee Oct 21 '14 at 08:54
  • yeah I did , and the bash did run, but no output file , just tons of gibberish on the terminal window :( – David Gidony Oct 26 '14 at 14:11
  • Ok, try simplifying the script to just the first line, then `echo hello` on the second line, then `read z` on the third line. Put a hash (`#`) at the start of all your other lines to comment them out. – Mark Setchell Oct 26 '14 at 14:22