Skip to content

Instantly share code, notes, and snippets.

@brunopadz
Last active April 22, 2018 14:39
Show Gist options
  • Save brunopadz/603e00850854e8038d326958ea53361c to your computer and use it in GitHub Desktop.
Save brunopadz/603e00850854e8038d326958ea53361c to your computer and use it in GitHub Desktop.
Simple shell script to copy files over ssh
FILES=source_dir/*BACKUP*
for f in $FILES
do
echo "Copying $f at `date`" >> copy.log
scp -i key.ppk -p $f user@hostname:/destination_dir
if [ "$?" = 0 ]; then
echo "$f copy has finished at `date`" >> copy.log
else
echo "Error while trying to copy $f" >> error.log
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment