LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-19-2007, 11:51 AM   #1
danrfxz
LQ Newbie
 
Registered: May 2004
Posts: 12

Rep: Reputation: 0
backing up data via ssh


Hi,

I have two computers on a network, say 192.168.1.10 and 192.168.1.20. Using Fedora's "connect to Server via SSH" I mounted my home fold on the .20 server on the .10 one. I was wondering if it's possible to automate the copying of my htdocs folder from .10 to a local backup folder, and from there to the .20 machine. I couldn't get samba or nfs to work ... and the SSH volume mounts and I can drag stuff over. Any help would be greatly appreciated.
 
Old 01-19-2007, 12:19 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,296

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Hi

When you have ssh access, you can use scp to copy from computer to computer. It works like the cp command, but prefix with "username@computer:" on the arguments.

E.g.
On source computer:
scp -r /var/www/htdocs username@192.168.1.20:~/backups/
Or on destination:
scp -r username@192.168.1.10:/var/www/htdocs .

It will ask for a password, to prevent that, you need to set up key based authenticaton on ssh so you can log in without a password.

Maybe look at
http://ssh.com/support/documentation...ication-2.html
(I googled "ssh public key")

When you have your command working, you can put it in cron.
 
Old 01-19-2007, 12:20 PM   #3
asommer
Member
 
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
Look into the scp command. For instance:

scp some_source_file username@machine:/path_to_destination

or for a directory:

scp -r some_file username@machine:/path_to_destination

This will also work from the other direction

scp username@machine:/path_to_source_file /destination_path

and if you setup a public key with ssh you won't have to enter a password.

Last edited by asommer; 01-19-2007 at 12:21 PM.
 
Old 01-19-2007, 12:22 PM   #4
asommer
Member
 
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
Ah...you beat me...heh
 
Old 01-20-2007, 08:00 AM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 417Reputation: 417Reputation: 417Reputation: 417Reputation: 417
You might want to check out using rsync as well. It works over SSH quite nicely and may have some advantages over scp depending on what you want to do.
 
Old 01-20-2007, 05:55 PM   #6
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
An example of rsync with ssh

rsync -av some_files -e ssh user@host:/path_to_dist

-a will archive directory including subdirectories
-v verbose optional
-e will use ssh for secure transfers

Rsync will keep logs of file changes. When you
run this command in the future, only new or updated files
will be transferred.
 
Old 01-21-2007, 12:26 AM   #7
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Quote:
Originally Posted by dv502
rsync -av some_files -e ssh user@host:/path_to_dist

-a will archive directory including subdirectories
-v verbose optional
-e will use ssh for secure transfers

Rsync will keep logs of file changes. When you
run this command in the future, only new or updated files
will be transferred.
might as well as stick in the -z (compression) and --delete (sync up folders) options
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
backing up Evolulion Data impeteperry Ubuntu 2 06-20-2006 07:24 PM
backing up data to a CD-RW joshknape Linux - Software 2 01-08-2006 01:35 AM
Backing Up Data? carlosinfl Linux - Networking 4 12-31-2005 12:05 AM
Need advise regarding backing up data before resizing hi-clier Linux - Newbie 3 10-20-2004 01:48 PM
Problems backing up data ptom98 Linux - Security 3 07-31-2003 04:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration