Automatically backup web server data with WinSCP via FTP

For website system administrators, data backup and recovery must always be the top priority. And in fact, there are many ways to do this that are applied daily. In the following article, we will show you how to do this with the free WinSCP tool and a little knowledge.

TipsMake.com - For website system administrators, data backup and recovery must always be the top priority. And in fact, there are many ways to do this applied daily. In the following article, we will show you how to do this with the free WinSCP tool and some basic knowledge of code.

In essence, the FTP protocol - File Transfer Protocol is a form of data transfer between many different computers. Formed and developed over a long time, FTP and SFTP - Secure File Transfer Protocol are still the most popular protocols in the world today. To apply for the test below, you need to prepare:

- Server FTP

- Computer using Windows operating system

- WinSCP version - for Windows

Set up WinSCP:

The first thing we need to do here is to install WinSCP on a Windows computer:

Picture 1 of Automatically backup web server data with WinSCP via FTP

Then, you need to create a new one section profile to use in later sessions. At the Login screen, we enter the host name (eg ftp.howtogeek.com ), Username and Password , select FTP or SFTP , change the appropriate Port value. Then click Save to save this profile:

Picture 2 of Automatically backup web server data with WinSCP via FTP

Create Script:

Here, we will create a simple code for the system to log in to the FTP server, communicate with WinSCP to download the missing files, then create a log file to record all FTP operations. To get started, open NotePad and copy the code below:

batch tùy chọn
tùy chọn confirm
open patrickbisch@ftp.howtogeek.com
cd backups
tùy chọn chuyển đổi binary
get / testremote * f: backupstestlocal *
synchronize local f: backupstestlocal testremote
exit

Specifically, WinSCP will automatically respond to system notifications to avoid interruption in the middle of operation, then overwrite newly created files. Continue, log in to the FTP server based on the profile created above, change the directory structure (if necessary), pass the binary code (as opposed to ASCII ). Finally, the application will filter the diagram, FTP directory structure on the remote server, and transfer the necessary files to the specified directory. You can refer here .

Before running or editing this script, you should create a test directory on local and remote computers (to avoid possible confusion). On the local machine, we create the testlocal directory (here is F: backups ) and testremote on the FTP server. Then, run the script, if successful, save the above code into any folder on your computer.

Set up automatic mode for scripts:

For the rest of the process, we'll let Windows do it - based on the built-in Task Scheduler feature. You open Control Panel> System and Security> Administrative Tools> Task Scheduler:

Picture 3 of Automatically backup web server data with WinSCP via FTP

In the right window, click Create Basic Task:

Picture 4 of Automatically backup web server data with WinSCP via FTP

Give a short name and description for this operation, click Next to continue:

Picture 5 of Automatically backup web server data with WinSCP via FTP

The next option is the operation mode over time, in this test, we want the script to run every time the computer starts. So you choose When the computer starts:

Picture 6 of Automatically backup web server data with WinSCP via FTP

On the next screen, select Start a program and click Next . The system will ask us to point the path to the file to be executed. Click the Browse button and point to C: Program FilesWinSCPWinSCP.exe . Below, you enter:

/ console /script=f:backupsync.txt /log=f:backuplog.txt

Picture 7 of Automatically backup web server data with WinSCP via FTP
Change the details at this argument as appropriate

After that, the system will display all general information as well as details of the whole process, check again and click Finish . And to make sure the system will work as expected, you should click the Run button to make sure there are no errors arising:

Picture 8 of Automatically backup web server data with WinSCP via FTP

Very simple and easy, wish you success!

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile