I have debian 7 x64.

I want to automatically zip a directory /ftb and place it in a directory /backup. I want it to be named Backup: (system date). I used apt-get install to install zip package, so I can use that to zip a file.

For example, if it were created on February third, 2014 it would be named Backup: 2/3/14 and placed in /backup.

Is this possible?

up vote 2 down vote accepted

Yes. You can create a script that will do what you want and run it via cron.

The script would be something like this

#!/bin/bash
zip -r /backup/Backup-$(date +%Y-%m-%d) /ftb

Which will create a file with the name Backup-2013-12-31, which is located in /backup, and have the contents of the /ftb directory

Then you can make the script executable, and add it into the crontab to run the script daily or however often you run it.

To do it daily, you could just use the daily directive in the crontab -
run crontab, and then add the following line

@daily /path/to/backup/script
  • Awesome script, I love it. Using it to backup my home partition, and my www folder, and mysql folder. – crosenblum Apr 24 '14 at 20:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.