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:
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:
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:
In the right window, click Create Basic Task:
Give a short name and description for this operation, click Next to continue:
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:
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
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:
Very simple and easy, wish you success!
You should read it
- Instructions for backing up and storing data on your Android device securely
- How to back up automatically on Windows 10
- Delete log information in Windows Server Backup
- How to use Iperius Backup Free to back up Windows data
- Instructions for using File History to backup and restore data
- How to backup data on iPhone or iPad
- 4 ways to manage the process of Backup Windows Server 2008 on multiple servers
- Install Windows Server Backup on Windows Server 2008 R2
- Things to keep in mind when backing up data on your computer
- Instructions for backing up all data on Android device without root
- 5 solutions to backup local Mac to replace Time Machine
- Windows 11 is about to have a new 'Backup' application