Sigh.. or just use sftp using LFTP.
This was of particular interest for my compiled website project.
Table of Contents [hide]
Tools needed ∞
- SSHFS -- Remotely mount an SSH folder.
- rsync -- Too fucking braindead, needed MAJOR work.
- sed -- Its use can be tidied up
-
Ruby -- Could/should be eliminated
Scripts created ∞
mount-root.sh ∞
Run this as root once, to prep the mountpoint.
# as root echo " # Mounting" sshfs -o allow_other username@example.com:/var/www/vhosts/example.com/ /mnt/mnt
sync.sh ∞
INSTALLATION=/path/to/httpdocs RSYNC=$INSTALLATION/../rsync.txt RSYNC2=$INSTALLATION/../rsync2.txt echo " # running rsync --dry-run to get a list of new files" rsync --dry-run -vrlt $INSTALLATION/ /mnt/mnt/httpdocs/ > $RSYNC echo " # processing the rsync file to remove the header/footer" # nuke the first line sed '1d' < $RSYNC > $RSYNC2 # nuke the last three lines sed -e :a -e '$d;N;2,3ba' -e 'P;D' < $RSYNC2 > $RSYNC rm $RSYNC2 echo " # Running ruby script to nuke updated files from the remote server" ruby sync.sh.rb rm rsync.txt echo " # Synchronizing new/updated files" rsync -vrlt --delete $INSTALLATION/ /mnt/mnt/httpdocs/
sync.sh.rb ∞
It's badly done, but it works
# For each of the items in a file, delete the file $INSTALLATION="/mnt/mnt/httpdocs" def nuke_it(file) output_where = "top" File.open(file, 'r').each { |line| filename = File.join($INSTALLATION,"",line) # I can't do an "if exists" properly, oh well. exec "rm -f " + filename } end nuke_it("rsync.txt")
Last updated 2019-11-16 at 18:58:42
ported