Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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