Web Hosting Talk







View Full Version : Need some help with SSH command


Tazzman
06-06-2002, 05:41 PM
Well, what I'm basicly trying to do is copy the entire content of a folder (including all subdirectories and files in them) to a backup on a second harddrive. I'd just like to know if there's a command for this in SSH like xcopy in DOS. I did try to make the backups with reoback, but it keeps giving me a load of errors, so I guess I'll have to do it by hand.

Any help appreciated.

ScottD
06-06-2002, 05:50 PM
Try scp, it's rcp using ssh.

edit
oops, guess I should have consumed the message better before posting, I was thinking you wanted to copy via ssh. Ffeingol is correct.

ffeingol
06-06-2002, 05:58 PM
cp -Rp /source /dest

-R is recursive -p is retain permissions/ownership. You prob. won't be able to use the -p part unless you are root.

Frank

Tazzman
06-06-2002, 07:13 PM
Hmm, looks like the cp command just creates symbolic links back to the data on the first drive, that's not what I'm trying to achieve. I want to make a real backup of the data on drive 1 on the second drive so it is physicly (sp?) on both drives...

Thanks for trying though...

Should say that I want this data on drive 2 as I will be formatting drive one to install Redhat 7.2 and the new version of Ensim as soon as I have the backups made.

ffeingol
06-06-2002, 07:30 PM
cp does not create symbolic links (unless the file is a link). cp is the *nix copy command.

If you're doing this for backups, look at rsync (http://www.samba.org/rsync/). rsync will just copy what has changed.

Frank

Tazzman
06-06-2002, 07:33 PM
Yeah, you're right, they're symbolic links themselves, just noticed. Darn this Ensim file structure, symbolic links everywhere ... :stickout

Found the folders I really needed, thanks for your patience. Anybody happen to know a site where all the SSH commands are listed. I am learning as I go along, but a reference would be nice :)

FHDave
06-06-2002, 08:04 PM
Originally posted by Tazzman
Well, what I'm basicly trying to do is copy the entire content of a folder (including all subdirectories and files in them) to a backup on a second harddrive. I'd just like to know if there's a command for this in SSH like xcopy in DOS. I did try to make the backups with reoback, but it keeps giving me a load of errors, so I guess I'll have to do it by hand.

Any help appreciated.

Since this is just for a backup purpose, why not use tar?

'tar -cf target_filename.tar source_directory/'

You will get one tar file and later on you can unarchived this. The good thing about tar is that since it will produce only one file, you can then gzip it to save some space

'gzip target_filename.tar'

Good luck

regards,
-dave

ffeingol
06-06-2002, 08:26 PM
I was guessing that Tazzman just wanted to backup certain directories to a second drive. If that's the case, rsync is great for that.

If you're going to use tar, save yourself a step.

tar -czf you-tar-file.tar.gz /some/input/

The gnu version of tar (on most Linux boxes) takes the -z parameter which will do the gzip on the fly.

Frank

Tazzman
06-06-2002, 08:31 PM
I have no need to tar the files as I have 2 40 gig drives, I can just mirror and save myself some time :)

Rsync looks nice. I'll have to have a look if I can add it to cron once I have Redhat 7.2 installed and the server back into good condition...

ffeingol
06-06-2002, 08:39 PM
Yep,

rsync is very easy to cron. Look at their examples page and you'll see some good methods for setting up scripts.

Frank

xerocity.com
06-06-2002, 09:03 PM
When you tar a directory and all files in it, will it still retain its permissions?

What is the command to download a file via SSH?

Tazzman
06-06-2002, 09:21 PM
depends, if you just want to download a file from an ftp or website it would be:

wget ftp://123.456.789.10/filename.zip or wget www.files4all.com/filename.zip

RutRow
06-06-2002, 10:09 PM
Originally posted by xerocity.com

What is the command to download a file via SSH?

scp

Try man scp