Script to copy a file remotely using winscp

Create a shell script and copy the below code to the file. Later you can run this script to execute the commands automatically

#command to connect to the remote server using winscp
winscp  sftp://username:password@serveripordomain/ -rawsettings SendBuf=0

#tar and zip a folder before copying it. use --exclude to exclude files
call tar -czf archive15dec2022.tar.gz /path/to/folder/youwanttocopy

#get the file to your local pc/server and deleting it from the remote server
get -delete archive15dec2022.tar.gz 

#below command to remotely zip a mysql database and get the sql file
call mysqldump -umysqluser -pmysqlpassword dbname > archive15dec2022.sql
get -delete archive15dec2022.sql


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.