Off-site mirroring scheme using rsync, sshfs and encfs too slow to be usable
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Off-site mirroring scheme using rsync, sshfs and encfs too slow to be usable
I have a scheme using rsync, encfs and sshfs that mirrors my data off-site.
I like it because I don't mirror junk (because I can use rsync's --exclude), and it doesn't require a local copy to be made (because of the encfs mount point).
So the data flow looks like:
rsync of my data -> encfs mount point -> sshfs mount point
It's really really slow, though. Unusably so.
Turns out simply rsync'ing to the sshfs mount point is slow.
cp is fine (floods the connection).
This seems like something easy to search Google for and linuxquestions.org, and indeed I have. I've tried a few recommended sshfs options with no change.
It's hard to debug since rsync does different things at different times, but mostly the symptom is:
My CPU is mostly idle
The connection is mostly idle
Each <100KB file that's being processed takes 10+ seconds
If I strace -f -p the head rsync process (there are three spawned for some reason), I see it sitting on a select:
A simpler command line does the same thing (but is even slower since it's more interactive with the remote site due to trying to preserve permissions, times, etc.)
The --delay-updates I threw in there as an experiment, and it makes the initial flurry of lstats go very fast, but then it slows to the 2 seconds per file pace.
Targeting other machines over the internet is the same.
Targeting a machine on my LAN is fine (floods the connection). This is probably the least logical result.
Rsync using ssh transport to the same machine is fine (floods the connection).
What do I try or look at next?
Last edited by gbell12; 07-31-2016 at 08:30 PM.
Reason: change 'backup' to 'mirror'
Update: I mistakenly thought strace -f <parent pid> would trace all three rsync processes simultaneously. If I do strace all three, I see the last one is waiting on a select, as documented above, but the other two are doing 100s of seemingly useless operations like this:
Code:
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/.~tmp~/php.variable.shortName.storage.values", 0xbf89a8e4) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/php.variable.shortName.storage.values.at", 0xbf89a944) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/.~tmp~/php.variable.shortName.storage.values.at", 0xbf89a8e4) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/php.variable.shortName.storage.values.s", 0xbf89a944) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/.~tmp~/php.variable.shortName.storage.values.s", 0xbf89a8e4) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/php.variable.shortName.storage_i", 0xbf89a944) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/.~tmp~/php.variable.shortName.storage_i", 0xbf89a8e4) = -1 ENOENT (No such file or directory)
lstat64(".PhpStorm2016.1/system/index/stubs/php.variable.shortname/php.variable.shortName.storage_i.len", 0xbf89a944) = -1 ENOENT (No such file or directory)
Some years ago, I struggled with the same problems. I wanted to send a backup to a remote server with rsync, and I was worried about the remote server. It could get stolen or something, and I didn't want them to be able to read all the backup files. Like you, I had problems because it was terribly slow. I never really solved the problem, but I found 2 different workarounds.
1) Don't use sshfs. Instead just use encfs on the remote server, and use rsync normally (over ssh). Something like this:
This is a lot faster. The downside is that you have to trust root on the remote server. Root can read all the files while the backup is being done, sniff the password, or do other nasty things. But in my situation, I was more worried someone would actually steal the server by breaking into the house. When the server is turned off, it's automaticly unmounted. So then all the files are encrypted, and the password to decrypt is not stored anywhere.
2) If you have lots of diskspace, you can use rsync locally first to an filesystem with encfs. Then unmount the enfs filesystem, and rsync the encrypted files. This is a safer solution, but it takes double the disk space on the local machine.
I'd say you definitely need to talk to the remote admins.
What it sounds like is that anything thing that looks like network socket cxn is bandwidth limited at one end or the other (or both).
(It may be case that even for an rsync that appears to a 'local' copy job, it still uses network sockets)
cp itself doesn't use an explicit network socket (although its a remote mnt 'underneath'). I'm not quite sure how cp really works for a remote mnt here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.