What is the efficient way to remotely copy a tar.gz file or a folder contents over a network in c++ programmatically
Hi,
I need to copy an entire directory from one host to other programmatically in C++. My directory contains different file types like .dlt .png etc.. I am ok with either 1. taring the entire directory and copy the tar file to a remote machine. Or 2. copying the directory as such. my directory size range between 400 to 500MB Please throw some light on this, to proceed further. Also i appreciate if you share some code snippets to achieve the same. |
did you try to look for a solution on the net?
the language is more or less irrelevant, the implementation depends on your connection and connection type. you can use scp, ftp, rsync, nfs, samba or something else. |
Guess it would be a "tar -czf - ... | ssh ... 'tar -xzf -'" pipeline, called with system(3).
|
Quote:
|
Quote:
It was just a request that i made here to share the code snippet if any since i was unable to find a reference impl, anyhow no issues cool.. |
https://github.com/KrishnaChaurasia/...-file-transfer
i just tweaked the above reference implementation as per my use case and it worked well. :) thanks everyone here, for your inputs.. |
something to consider
how likley is it that a file will change during the archive? will it matter? for instance files aaa.db and zzz.db are related in some way aaa.db gets tared but by the time you reach zzz.db it has changed and effects aaa.db in some way. one solution to this problem is snapshots, where the filesystem takes snapshot intime and you then transfer that snapshot without worring about file updates |
In my case the files will not be altered while taring the folder.
|
You could shorten yoru error handling from this:
Code:
fd=socket(AF_INET,SOCK_STREAM,0); Code:
|
All times are GMT -5. The time now is 08:08 PM. |