< All Topics

WinSCP Backup Script Tutorial

Please note that this is a Hosted~FTP~ resource, scripting support is available to our Enterprise level customers.

Utilize this WinSCP backup script to protect your files using an automated process that helps ensure the integrity and safety of your files. In this tutorial, learn how to use WinSCP in collaboration with WebDrive to automate file backups with HostedFTP.

 

Requirements

To back up your files, you’ll need 3 requirements:

  1. WinSCP (free)
  2. WebDrive
  3. A HostedFTP group account or higher.

 

Video Tutorial

 

Instructions

To setup the WinSCP backup script, follow the instructions below:

Setup your account for backing up files:

  1. Go to the Users Tab and click “Add username” located on the right hand menu.
  2. Create a backup user. Fill in the login credentials and save once complete.
    Make sure not to give the user a storage or bandwidth quota.
  3. Next, click “Login” beside the user’s username and use your admin password to login.
  4. Go to the Files Tab and create a backup folder in the root directory i.e “/”
  5. Share the new folder with any users you want to give access to the backup folders (optional).

Remember this backup user’s login credentials and folder name.

Setup WebDrive for backing up files:

  1. Connect to your backup user account using the login credentials in the previous step.
  2. Take note of the mounted drive i.e Drive A:
  3. Take note of the folder name i.e backup

Setup WinSCP for backing up files:

  1. In the site manager, input your login credentials for your admin account, or as the user who’s files you want to back up.
  2. Click save and change the site name to something you will remember (optional).
  3. Check “Save password”.
  4. Review your remote site. Make sure all files and folders you want to backup are located inside one directory.
    To specify a specific directory, take note of the folder path i.e mainfolder/subfolder1

Create a script to back up files part 1:

  1. Locate the Notepad program. Right click the program and select “Run as administrator”.
  2. Insert the following script: winscp.exe /console /script=script.txt
  3. Save the file using the following settings: Save as type: All Files and File name: script.BAT

Create a script to back up files part 2:

  1. Once again, locate the Notepad program. Right click the program and select “Run as administrator”.
  2. Insert the following script but using your own credentials where necessary:
    open adminlogin
    mget -neweronly /MainFolder A:\backup
    a: the name of the site connection you created in WinSCP
    b: WinSCP folder path of the folder you want to backup
    c: WebDrive backup folder path including the mounted drive
  3. Save the file as: script.txt

Create a script for backing up files part 3:

  1. Locate and open the program folder for WinSCP.
  2. Click and drag both files into the WinSCP folder.
  3. Double click script.bat to run the script.

You can use window’s task scheduler to set a time for when you want the script to run.

NOTE: If you change folder names with this setup, all files, folders and sub-folders will be downloaded and uploaded into the new folder name. Personal accounts do not support automation.

Click Here for more Videos and Tutorials

Table of Contents