Looks like my backup script it's excluding all the directories I've specified except for one /var/backups which contains the tar file just created with the script. What am I doing wrong?

I've already followed the suggestions in this post.

Here's my script:

tar -zcpf /var/backups/"full_system_backup_$(date +%Y%m%d_%H%M%S).tar.gz" --directory=/ --exclude=/var/backups --exclude=proc --exclude=sys --exclude=dev/pts .
  • 1
    Should --exclude=/var/backups really be --exclude=var/backups ? – Stephen Harris Jun 15 '16 at 1:20
  • 1
    probably so. because --directory already is set to /........ let me try that and see – Kismet Agbasi Jun 15 '16 at 1:36
  • @StephenHarris thanks, your suggestion was spot on. Mind answering the question so I can accept it? Or should I just go ahead and answer it myself? – Kismet Agbasi Jun 15 '16 at 1:48

The entry --exclude=/var/backups should read --exclude=var/backups to match the pattern expected by tar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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