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:
- Retrieve the MD5 checksums and directory list from the remote server a using sftp.
- Compare these with the current files and directories.
- Get the files that need to be added using sftp.
- Delete the files that are no longer needed.
- 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:
- Find some clever bash-trickery to make sure that I can keep one sftp-session open. But so far that does not seem promising.
- Use expect. Very good solution, but the urge to make the program rely on Bash and sftp is very big.
- Use something like Perl and Net::SSH. See 2.
- 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….