2

I have 2 systems

1: 192.168.0.31 
2: 192.168.0.32

From system 1 terminal I executed below command

tar -zcf - test | pv | nc -l -p 5555 -q 5

From system 2 terminal I executed below command

nc 192.168.0.31 5555 | pv | tar -zxf -

Now full test folder with all containing files copied to system 2

How can I to schedule both commands using crontab or something else?

Yaron
  • 13,173
shaji
  • 51
  • You should really do that using SCP, doing this with NC is very unsecure as there is no authentication or encryption whatsoever involved. – Gewure Aug 24 '17 at 13:50

1 Answers1

2

It seems that you would like to make a backup/copy of data in one computer into another.

A very simple and secure solution might be using scp which is based on ssh.

scp sample command might look like:

scp -r /path/to/local/folder user@remotehost:/path/to/remote/folder

e.g.

  • Assuming that:

    • your username is shaji
    • You wan to copy files from 192.168.0.31 /home/shaji
    • To 192.168.0.32 into folder /backup/shaji/backup
  • You should run the following command on 192.168.0.31:

    scp -r /home/shaji shaji@192.168.0.32:/home/shaji/backup

Note: You can run the scp command using crontab

man scp

scp — secure copy (remote file copy program)

DESCRIPTION

 scp copies files between hosts on a network.  It uses ssh(1) for data
 transfer, and uses the same authentication and provides the same security
 as ssh(1).  Unlike rcp(1), scp will ask for passwords or passphrases if
 they are needed for authentication.

 File names may contain a user and host specification to indicate that the
 file is to be copied to/from that host.  Local file names can be made
 explicit using absolute or relative pathnames to avoid scp treating file
 names containing ‘:’ as host specifiers.  Copies between two remote hosts
 are also permitted.

 -r      Recursively copy entire directories.  Note that scp follows
         symbolic links encountered in the tree traversal.

There are some pre-requites:

  • sshd should run on the remote host
  • Setting password-less ssh access to remote host - see askubuntu Q&A
Yaron
  • 13,173