H
H
homm2011-06-13 08:32:48
linux
homm, 2011-06-13 08:32:48

How can I do multiple things with one ssh connection?

I want to put a cron script that will backup data via ssh. Backup, in theory, will consist of three actions:

1) Copy the previous backup to a new folder with hardlinks. Looks like this:
ssh [email protected] cp --link from/ to/

2) Upload database backup. Apparently, like this:
scp database.tar.gz [email protected]:to/

3) Synchronize new files with rsync

These are only required and obvious steps. Of the non-obvious - you need to get a list of directories to find out where to copy in the first paragraph. Sometimes you will need to thin out old backups.

The question is: each of these commands will establish its own ssh connection. Maybe, of course, this is not so long compared to the time of the backup itself, but still it is not kosher. Is there a way to do this all through a single ssh connection?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
K
kondor, 2011-06-13
@homm

Perhaps you should look towards the "-M" switch for ssh. This option allows you to use an already established connection to a remote host for new ssh sessions with the same host. A little more detail with a small example: www.linuxjournal.com/content/speed-multiple-ssh-connections-same-server

M
mihmig, 2011-06-13
@mihmig

try mounting the remote filesystem via sshfs

C
ComodoHacker, 2011-06-13
@ComodoHacker

In my opinion, what you want is already invented and debugged, and is called rsnapshot

H
hshhhhh, 2011-06-13
@hshhhhh

Well, the first can be combined with the second, but in order to download in two streams (base and rsync), you will have to make two connections.
And getting a list of directories and thinning backups is better to shove into a script on the other side. Even better in crowns.

P
phasma, 2011-06-13
@phasma

Maybe Bacula?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question