Bloggings

Home

Upload modified blog files with scp

2025-03-29

A simple bash script to update this blog using scp

Note

I have my web server aliased in ~/.ssh/config as "web"
so the remote folder is web:/folder

#!/bin/sh # blogsend : scp blog files to web server # usage : blogsend hours (if not set default is 1 hour) # example : blogsend 72 sends files modified over the past 3 days # folders rf= #add your remote ssh folder here mf= #add your local folder here cd $mf # test if option is sent if [[ -z "$1" ]]; then HOURS=1; else # test if option is a number if [[ "$1" =~ ^[0-9]+$ ]]; then HOURS=$1; else HOURS=1; fi fi MINUTES=$(($HOURS*60)) echo "Sending files modified in the past $HOURS hour(s)..." files=$(find * -path .tmp -prune -o -mmin -$MINUTES -type f) for file in $files do echo -ne "-> "; scp -r "$file" "$rf/$file"; done echo "Done." exit 0

 


A minimalist blog by Philip Wittamore