Hello Sitepoint,
After a good amount of RTFM on the tar command for *nix, I am backed into a corner and hope someone could point me in the right direction. I am currently trying to make a PHP script that will dump my database, and tar, bzip my public_html folder to a backup folder that I will potentially try to rsync to my local machine to move off site.
The database portion went great(Thanks to PHP anthology sitepoint book!), but now I am trying to come up with a similar class that will handle the public_html directory, and I just can not get the system command to work correctly.
Just some background, my back_it_up.php script(which will be the script that will handle the processing) resides in my home/usr/backups/ directory. My public_html directory from where my backup script is …/public_html/.
What I was thinking of doing would just to use PHP to run another system command like so:
tar cvfj backup.tar.bz2 -C ../ public_html
This works fine for the public_html folder, but there is one particular folder I would like to archive, zip seperately that is inside public_html and I would just like the contents of that directory. So then I try this:
tar cvfj seperateDir.tar.bz2 -C ../ public_html seperateDir
And what I get is all of public_html and seperateDir, including the folder when I just want the contents. I have looked exhaustivly at resources on the tar command, but all the examples I find do not necessarily cover what I am trying to do. Does anyone have any thoughts or suggestions? Or possibly point me in the right direction? I am assuming this is so simple that I have missed in completely and I will feel like…well you know when I finally find the solution.
Thanks Sitepoint!