Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking for any solution that will allow me to emulate functionallity similar to Dropbox/rsync using only FTP protocol and command-line.

The general problem is, that I have to run it on a very limited Linux (actually NAS), so I can't install / use to complex solutions (not enough resources to run) and/or GUI utils, as I have no GUI there. SSH also works weak on that NAS and is not present at all on one of destinations.

What I need, is to have a command-line (bash) script or program that I will be able to run periodically (via CRON) that will assure that source and destination are identical:

  • all files on both sides copied to both sides,
  • if two files of the same name exists, copy newest version of a file to both sides,
  • delete on one side all files that are missing on another one.

Of course, this solution must support iteration on all subfolders of both source and destination, for this to work succesfully -- there will be a large directory structure on both sides.

I've tried many backups solutions, but most of them failed for one of these reasons:

  • unable to create exact duplicate copy of both sides and offering incremental backup instead,
  • not able to be run directly from command-line, on very limited Linux distro.

I was advised to use Unison and give it a good try. This really looks good, but it uses SSH, and I'm unable to establish SSH connection to one of my destinations (not supported) -- i.e. FTP access is the only available way.

The perfect solution for me would be anything that I can run (command-line or configuration) like this:

something.sh path/to/local/folder ftp://user:pass@111.11.11.1/path/to/folder

If it does exists at all...

share|improve this question
    
Could you clarify what you have on the NAS side (FTP server, client or both) and what you have on the other side? Do you need to be able to synchronize between two limited machines, or can you arrange to always transfer between a limited-machine and a less-limited machine? –  Gilles Oct 9 '12 at 21:58
    
@Gilles: First option: I have a limited NAS (has rsync and ftp but lacks many system-level commands, clients, services and programs) and even more limited video-player that actually gives out nothing else except FTP (and Samba). To make things even more complex, both devices are not in the same network and are accessible only via external IP (NAS has it own, player is behind NAT and uses DynDNS to workaround dynamic IP address problem). –  trejder Oct 10 '12 at 20:07

2 Answers 2

One general thing: as far as I know, ftp cannot be used to set the remote time stamp, because this is not supported by the protocol. However, this is OK in your case, since you only want to make sure that data that is newer than that on the server is transferred, and the rest left.

I think that you can use rsync with ftp using fuse and curlftpfs. First, mount the ftp filesystem locally:

curlftpfs -o user=username:password ftp://whatever.ftp/ mountpoint/

Then, use rsync the usual way for local mirrors:

rsync -azv source mountpoint/whatever/dir/

rsync is a powerful tool with many options to fine tune the synchronization of folders and files.

Another option: wput; this (written I think as a counterpart to wget) can compare remote and local time stamps using the -N option. Furthermore, wput recursively transfers the directories, so I think that this is actually the solution that you are looking for. Example:

wput somedir ftp://user:pass@some.server/remote/dir/

Will create a mirror of "somedir/" on the remote server. If you re-run the command without modifying the local somedir, no further files will be transferred.

share|improve this answer
    
Hm... I'm a Linux newbie, but I have to revalidate my knowledge. All my sources about rsync that I have read always claimed: You want to use rsync over FTP? You need to find another way to do this. rsync does not work that way! Look here and here for example. –  trejder Oct 9 '12 at 10:44
    
You are right, silly me. I revised the answer. –  January Oct 9 '12 at 11:05
    
This does sound interesting, unfortunatelly, there is no curlftpfs on my NAS and no way to install it. I asked for FTP, because this is all I have there. I'll give a try to wput, but after first look it looks only like a file-transfering tool, so I would have to do all the magic (that rsync does) of finding and sending only modified files myself. I'm pretty sure that it is more than I can handle due to my limited knowledge of Linux/bash. –  trejder Oct 9 '12 at 11:22
    
Well, the -N option of wput takes care of some of your problem. –  January Oct 9 '12 at 11:23
    
P.S. and wput is recursive, so no need to find the files yourself. –  January Oct 9 '12 at 11:36

lftp has a mirror command (and mirror -R for reverse mirror).

share|improve this answer
    
This does sound interesting, unfortunatelly, there is no lftp on my NAS and no way to install it. I asked for FTP, because this is all I have there. If installing addtional software would be an option, I would problably solve this problem myself, without asking. –  trejder Oct 9 '12 at 11:23
    
lftp is a FTP client. It would talk to the FTP server on the NAS. Do you mean you need to synchronise two NASes directly between each other. –  Stéphane Chazelas Oct 9 '12 at 11:29
    
@trejder If installing additional software isn't an option, why did you "try many backup solutions"? You already knew you couldn't install them! Please state your problem accurately. –  angus Oct 9 '12 at 18:41
    
@sch: Exactly as in my answer to Gilles comment above: Two devices in two different networks, one is NAS, second is video-player with some unknown distro on-board, able to be access only via FTP (and Samba). –  trejder Oct 10 '12 at 20:08
    
@angus: Maybe "many" is to strong word. I've tried rsync+mounting external system (faild) and unison (also failed). Installing additional software is an option, but only if that software is available as IPKG package, because using Optware/IPKG is the only way to install something to that NAS. And AFAIK there is not IPKG package for lftp. –  trejder Oct 10 '12 at 20:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.