Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to schedule a cronjob on my server to backup the entire public_html directory daily. I am logged into cPanel and I am on the Cron Job page where I have it set to run this command everyday at 2am: tar -vcf /site_backup.tar /public_html/

Is this command sufficient for what I want to do? I want to store the contents of public_html in the site_backup.tar that resides in the root directory (one level up from public_html). Do I need to provide anything else in the command for it to run correctly?

share|improve this question

closed as off-topic by Jenny D, Sven Apr 14 at 15:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should demonstrate reasonable business information technology management practices. Questions that relate to unsupported hardware or software platforms or unmaintained environments may not be suitable for Server Fault - see the help center." – Jenny D, Sven
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

up vote 1 down vote accepted

That command would serve its purpose but is there any reason you aren't using any compression like gzip or bzip? Also since this is in a cron I see no real reason to have the -v flag, no need to see the output.

Just add a -z to your command flags for gzip.

So your final command would be:

tar -zcf /site_backup.tar.gz /public_html/
share|improve this answer

tar cvfz site_backup.tar.gz /path/to/your/user/public_html/ should be enough here, however it's better if you backup this using the cpanel functionality and do it to a remote ftp server.

Additionally you can use something like to backup you cpanel account, using it is pretty straight-forward(you just have to specify your server and accounts to be backed up).

share|improve this answer

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