Hello selfhosted! Sometimes I have to transfer big files or a large amounts of small files in my homelab. I used rsync but specifying the IP address and the folders and everything is bit fiddly. I thought about writing a bash script but before I do that I wanted to ask you about your favourite way to achieve this. Maybe I am missing out on an awesome tool I wasn’t even thinking about.
Edit: I settled for SFTP in my GUI filemanager for now. When I have some spare time I will try to look into the other options too. Thank you for the helpful information.
If this is Linux:
You can throw an entry in
/etc/hosts
to add a hostname mapping, even if you don’t want to set up DNS:It looks like bash has tab-completion for
rsync
paths set up by default these days on my Debian box. Will probably need to have passwordless or ssh-agent-based pub/privkey authentication set up in some fashion.If you don’t need
rsync
’s functionality – replicating attributes and reasonable resuming and doing partial copies – I tend to uselftp
, which supports sftp, an ssh-based file-transfer mechanism; one uses something likesftp://remotehost/remotepath
. That’s more-comfortable to browse, can bip around the local and remote filesystem with tab-completingcd
,lcd
,pwd
, andlpwd
and list remote files. Themirror
andmirror -R
command will move a file tree from or to the remote system.If you do want rsync’s “update changed files” functionality, and also want bidirectional synchronization in each direction instead of rsync’s unidirectional functionality — I do this to maintain a synchronized directory of videos that I want to be able to watch offline on various devices, among other things — I use
unison
. You can set this up to auto-synchronize a set of directories. If you’ve got a preconfigured set of directories to synchronize set up, just type “unison”, and bam.If I’m doing a lot of browsing and work on the remote end, I use emacs’s dired plus TRAMP as a rough approximation of a “two-pane file manager”, more-properly called an orthodox file manager.
emacs /ssh:remotehost:/remotepath localpath
will fire it up. TRAMP is pretty clever, tries to do stuff on the remote machine as much as possible – like, you can do stuff like version-control on remote directories and it’ll use git on the remote machine, can grep through the remote file tree without transferring the files locally, etc. That being said, this is probably mostly-applicable to users who already heavily use emacs, but it’s a handy technique if you have only a low-bandwidth connection and need to work on files remotely. I have emacs set up to default to using the “other pane” as a default target for things like copy and move commands using the following text in myinit.el
:If I’m wanting to play a video file remotely, I’ll sometimes do a sshfs mount using FUSE: