How to create a batch file in Mac?

前端 未结 1 1404
情书的邮戳
情书的邮戳 2021-02-11 00:57

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

相关标签:
1条回答
  • 2021-02-11 01:33

    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.

    0 讨论(0)
提交回复
热议问题