LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Move file from machine A to B on same network? (https://www.linuxquestions.org/questions/linux-newbie-8/move-file-from-machine-a-to-b-on-same-network-771086/)

Arty Ziff 11-23-2009 05:39 PM

Move file from machine A to B on same network?
 
I have two servers on my network (at home). Let's call them A and B.

I have a small shell script that I have written on server A that zips up a file, backs up a database. It's triggered by cron once a day.

After I run it, I would like to move this file from server A to server B.

As I said, both are on the same network (in the same room, actually), and so obviously have different network IPs.

What are my options to move these files? It would need to be something that was done in perhaps a shell script that was, like the shell script that zips the files, is triggered by a cron job.

I'm assuming there are actual applications for this sort of theng (rsync?), but can it be done with a shell script? It seems very simple and basic...

How might this be done?

Systems:

Server A - CentOS v. 5

Server B - RHEL v. 4

landysaccount 11-23-2009 05:46 PM

I'm currently backing up my server as well with a small script that would copy the tar file to the other.

Here's the script:


# created date: November 09, 2009
# description: This script will backup files
# update:
######################################################################

REMOTE_SERVER="172.16.0.3:/backup/"

BASE_DIR="/home/backup/"
SQL_FILE="mysqlfile.sql"

DATE=$(date +"%b-%d-%Y")

TAR_FILE="BackUp-$DATE.tar.gz"
MSD_DIR="/etc/msd"
DHCP="/etc/dhcp3/dhcpd.conf"
NOCAT="/usr/local/nocat"
SQUID="/etc/squid/squid.conf"
OPTIMUM="/home/landysaccount/optimum"
WWW="/var/www"

# back up mysql database
mysqldump optimum > "$BASE_DIR$SQL_FILE"


# create tar file backup
tar czf $TAR_FILE "$BASE_DIR$SQL_FILE" $DHCP $MSD_DIR $SQUID $OPTIMUM $WWW

# send to backup server
scp $TAR_FILE landysaccount@$REMOTE_SERVER

exit 0

#########################
Make sure you can login to the other server/machine without having to type a password.

Hope that helps.

i92guboj 11-23-2009 07:01 PM

There are indeed many ways. The big picture is this: you can choose to mount the remote volume, then just move or copy the file as you would copy it to another disk, using cp, mv, whatever. This can be done with nfs, sshfs, samba...

You can also choose to use a server-client model. In this case, you need to run a server in one of your machines, and launch the client in the other machine to literally upload your file to the server. This can be done usually with ssh (scp), ftp, rsync, and many other ways.

Both ways have advantages I guess, and often the line is thin. For example, if you have an ssh server running in your central machine, you can upload files to it by using either the scp file transfer tool, or by mounting the remote volume with sshfs and the using cp or mv to put the files inside the mounted share.


All times are GMT -5. The time now is 05:43 AM.