So I made this script to help me maintain my site. But it only helps me when I upload the site to the remote host. Suppose I want to work on the site from different machines. How can I then keep everything synchronized? The simple answer would be: assume that the remote site is the original and find out what the changes are compared
to the local copy of the site. The workflow would then become:

  1. Retrieve the MD5 checksums and directory list from the remote server a using sftp.
  2. Compare these with the current files and directories.
  3. Get the files that need to be added using sftp.
  4. Delete the files that are no longer needed.
  5. Delete and create local directories as needed.

My problem with this approach is that I need two separate sftp sessions, which means providing the system with at least my password twice. Since I want to
be as efficient as possible (read: I am Lazy :) ) I would rather give it once.

As I currently see it I have the following options:

  1. Find some clever bash-trickery to make sure that I can keep one sftp-session open. But so far that does not seem promising.
  2. Use expect. Very good solution, but the urge to make the program rely on Bash and sftp is very big.
  3. Use something like Perl and Net::SSH. See 2.
  4. Learn more about sftp and ssh2 to see if there is a possibility to keep session information for at least long enough to do all the work.

Decisions, decisions. If anybody out there has some good suggestions, feel free to contact me….