How to create a batch file in Mac?

前端 未结 1 1326
梦如初夏
梦如初夏 2021-02-11 00:40

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:22

    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)
提交回复
热议问题