I've done a search here and discovered that I can't gzip a whole directory - that I have to tar it first... but I can't seem to find any examples of how to tar a directory.
Ideally, I'd like to tar the directory, then gzip it appending the date to the filename, and place the gzip file in another directory.
Any pointers or sample code I could use as a start?
Thanks,
Scott
How to tar a directory?
Moderator: General Moderators
-
Sinemacula
- Forum Contributor
- Posts: 110
- Joined: Sat Feb 08, 2003 2:36 am
- Location: San Jose, CA
What's not explained in man tar?
Here's how i do it:
Here's how i do it:
Code: Select all
# generate tar-gzipped archive of homedirectory
tar -czf /tmp/backup.tgz ~
# move backup to homedirectory and change name
mv /tmp/backup.tgz ~/madoka-`date +%F`.tgz-
Sinemacula
- Forum Contributor
- Posts: 110
- Joined: Sat Feb 08, 2003 2:36 am
- Location: San Jose, CA
Thanks, timvw...
I hadn't looked at the man entry (not being much of a command-line user, it didn't occur to me)... but does it show how to make that work in a php script?
Here are some more details to help clarify what I'm looking for:
I've got a php script that pulls data from a mysql database and creates a separate file for each record and puts them all in directory1. What I want is for that same script to then tar and gzip directory1 and put the resulting archive in directory2.
Ideally, the script will then delete all the individual files in directory1 (but leaving directory1 itself).
So, what I need is to know if this is possible within a php script?
I have found some sample php code that will allow me to gzip a file and put the archive in a different directory, but I need something that will do a whole directory.
Thanks,
Scott
I hadn't looked at the man entry (not being much of a command-line user, it didn't occur to me)... but does it show how to make that work in a php script?
Here are some more details to help clarify what I'm looking for:
I've got a php script that pulls data from a mysql database and creates a separate file for each record and puts them all in directory1. What I want is for that same script to then tar and gzip directory1 and put the resulting archive in directory2.
Ideally, the script will then delete all the individual files in directory1 (but leaving directory1 itself).
So, what I need is to know if this is possible within a php script?
I have found some sample php code that will allow me to gzip a file and put the archive in a different directory, but I need something that will do a whole directory.
Thanks,
Scott
-
Sinemacula
- Forum Contributor
- Posts: 110
- Joined: Sat Feb 08, 2003 2:36 am
- Location: San Jose, CA