PDA

View Full Version : ssh - can we use it to .zip a folder?



nerdykit
07-14-2008, 06:14 PM
If we have ssh access, is there a command that we can enter via ssh to create a .zip archive of a specific folder? (The purpose is backing up just a segment of my space).

If yes, I'd like to know the syntax for a command that would create a specific .zip file of a specific folder (and its sub-folders) and deposit that .zip file into a specific directory (if all of that is possible)

If not via ssh, can this be done via a command in a php file instead (or alternatively)

Thanks

r2b2
07-14-2008, 07:21 PM
You'd want to do something like:

zip -r /home/myusername/myzipfile.zip /home/myusername/public_html/mydirectorytobackup

Alternatively (and recommended by me) would be to use tar and then gzip the final result - something like:

cd /home/myusername/public_html/mydirectorytobackup
tar cvzf /home/myusername/mytarfile.tar.gz *

(Note I'm not in front of an ssh session now so my commands may be a little off)

nerdykit
07-14-2008, 08:37 PM
Thanks r2b2, the tar command works beautifully, directly from terminal on my Mac. The only change I used was using -cvzf as the switches on the tar command.

Now I can back up selectively.

pghcollectibles
07-15-2008, 11:24 AM
another thanks from me. that will be convenient to download my test folders and backup already in a tar