{"id":928,"date":"2012-03-20T12:05:13","date_gmt":"2012-03-20T17:05:13","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=928"},"modified":"2012-03-20T12:05:13","modified_gmt":"2012-03-20T17:05:13","slug":"928","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=928","title":{"rendered":""},"content":{"rendered":"<h2><a title=\"How to Automatically Backup Your Web Server Files With WinSCP over FTP\" href=\"http:\/\/www.howtogeek.com\/100918\/how-to-automatically-backup-your-web-server-files-with-winscp-over-ftp\/\" rel=\"bookmark\">How to Automatically Backup Your Web Server Files With WinSCP over FTP<\/a><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp_lead\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp_lead.png\" alt=\"winscp_lead\" width=\"650\" height=\"300\" border=\"0\" \/><\/p>\n<p>You\u2019ve heard it time and time again: back up your data. There are plenty of backup solutions, but nothing is better than an easy and free solution. So with a few lines of code and a very helpful program called WinSCP, we\u2019re going to set up an automatic sync between your FTP server and your home computer.<!--more--><\/p>\n<p><a href=\"http:\/\/www.howtogeek.com\/100918\/how-to-automatically-backup-your-web-server-files-with-winscp-over-ftp\/\" target=\"_blank\">http:\/\/www.howtogeek.com\/100918\/how-to-automatically-backup-your-web-server-files-with-winscp-over-ftp\/ <\/a><\/p>\n<p>FTP (File Transfer Protocol) is an Internet protocol that allows users to transfer files between computers. Despite its old age (think pre-TCP\/IP era), FTP and its sister protocol SFTP (Secure File Transfer Protocol) are still very popular today and are viewed as an easy way to transfer files locally and over the Internet. It also happens to be a very good way to keep a remote backup of important files you keep on your FTP server.<\/p>\n<p><em>If you don\u2019t want to pay for a third-party FTP solution, check out this <a href=\"http:\/\/lifehacker.com\/339887\/build-a-home-ftp-server-with-filezilla\">article<\/a> on how to build your own FTP server written by the fine folks over at Lifehacker.<\/em><\/p>\n<h3>Requirements<\/h3>\n<ul>\n<li>An FTP server and access credentials<\/li>\n<li>A Windows computer<\/li>\n<li>A copy of <a href=\"http:\/\/winscp.net\/eng\/download.php\">WinSCP<\/a> (Windows only)<\/li>\n<\/ul>\n<h3>Setting Up WinSCP<\/h3>\n<p>Once you\u2019ve downloaded your copy of WinSCP, install the .exe on your computer. It also wouldn\u2019t be a bad idea to start remembering your FTP address, username, and password while WinSCP is installing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp1\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp1.png\" alt=\"\" width=\"539\" height=\"426\" border=\"\" \/><\/p>\n<p>Now that we have WinSCP installed, we\u2019re going to create and save a new session profile for easier access later on. From the login screen, enter your host name (i.e. <a href=\"ftp:\/\/ftp.howtogeek.com\/\">ftp.howtogeek.com<\/a>), username, and password. You can use either FTP or SFTP, but be sure to change the port number the appropriate port your FTP host has provided you. Then click Save to save the profile. Open the profile to log into your FTP server. This will verify that you typed the right credentials in the profile.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp2\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp2.png\" alt=\"\" width=\"567\" height=\"402\" border=\"\" \/><\/p>\n<h3>Creating The Script<\/h3>\n<p>We\u2019re going to create a simple script that logs into your FTP server, tells WinSCP where to download the missing files to on your computer, and then creates a log file that records FTP activity. Go ahead and open Notepad on your computer. Copy the following script template into Notepad:<\/p>\n<blockquote><p>option batch on<br \/>\noption confirm off<br \/>\nopen <a href=\"mailto:patrickbisch@ftp.howtogeek.com\">patrickbisch@ftp.howtogeek.com<\/a><br \/>\ncd backups<br \/>\noption transfer binary<br \/>\nget \/testremote* f:\\backups\\testlocal\\*<br \/>\nsynchronize local f:\\backups\\testlocal testremote<br \/>\nexit<\/p><\/blockquote>\n<p>Here\u2019s a brief explanation of what\u2019s going on in the script. WinSCP will answer all prompts negatively to avoid holding up the script. Then it will automatically overwrite files when prompted. It then logs into your FTP server using the profile we created earlier, changes directories (if needed), and transfers binary (as opposed to ASCII). Finally, it reads the remote FTP directory and transfers files to the specified local directory. For even more options, check out the official WinSCP <a href=\"http:\/\/winscp.net\/eng\/docs\/scripting\">scripting page<\/a>.<\/p>\n<p>Now before you modify or run this script, we suggest creating test directories on both the remote and local targets. The last thing you want is to accidentally wipe your FTP server without any backups. So create a directory on your computer called \u201ctestlocal\u201d (we created it under f:\\backups) and another called \u201ctestremote\u201d on your FTP server (we created it at the root). Once you run the script and it executes successfully, save it as \u201csync.txt\u201d to your computer (we saved ours in our testlocal folder). Now you\u2019re ready to automate the script.<\/p>\n<h3>Automating The Script<\/h3>\n<p>We\u2019re going to let Windows handle the automation by using its built-in Task Scheduler. In Windows 7, start by opening Control Panel &gt; System and Security &gt; Administrative Tools &gt; Task Scheduler.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp3\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp3.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>In the right column, click the Create Basic Task button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp4\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp4.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>Name and describe your task, and then click Next.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp5\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp5.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>The next option will determine how often the task will run. We chose to run the script every time we turn our computer on. You can choose a less frequent option like Weekly to run it less often.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp6\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp6.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>On the next screen, choose \u201cStart a program\u201d and click Next. You\u2019ll be prompted to browse for a program or script. Click the Browse button and navigate to \u201cC:\\Program Files\\WinSCP\u201d to select the WinSCP.exe. Underneath, add \u201c\/console \/script=f:\\backup\\sync.txt \/log=f:\\backup\\log.txt \u201c to Add arguments. Be sure to change the arguments if your sync.txt is in a different location and if you want to generate the log file in a different location. Click Next.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp7\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp7.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>You\u2019ll see a summary of your task. If it looks correct, click Finish. Finally, to ensure the task runs properly, we\u2019re going to run it. Make sure you have at least one file in your testremote directory (i.e. \u201cthisisatest.txt\u201d). Highlight your newly created task and click Run in the right column. You should see a command prompt appear, connect to your FTP server, and then sync the file(s).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"winscp8\" src=\"http:\/\/www.howtogeek.com\/wp-content\/uploads\/2011\/12\/winscp8.png\" alt=\"\" width=\"650\" height=\"392\" border=\"\" \/><\/p>\n<p>Your test task should have completed, and your test file should now be in the specified local folder. If you run into any errors, check the log file to find out why.<\/p>\n<p>That\u2019s all there is! You now have a free backup solution that will keep all your FTP files synced to a local folder. Should your FTP server ever crash or you accidentally delete a file, you can recover the copy from your computer!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Automatically Backup Your Web Server Files With WinSCP over FTP You\u2019ve heard it time and time again: back up your data. There are plenty of backup solutions, but nothing is better than an easy and free solution. So &#8230; <a class=\"more-link\" href=\"http:\/\/www.wildow.com\/blog\/?p=928\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-928","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=928"}],"version-history":[{"count":2,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/928\/revisions"}],"predecessor-version":[{"id":930,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/928\/revisions\/930"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}