{"id":2852,"date":"2020-06-14T11:13:49","date_gmt":"2020-06-14T04:13:49","guid":{"rendered":"http:\/\/rachmadona.net\/?p=2852"},"modified":"2020-06-14T11:13:49","modified_gmt":"2020-06-14T04:13:49","slug":"scheduling-transfer-files-via-ftp-sftp-use-winscp","status":"publish","type":"post","link":"https:\/\/rachmadona.net\/?p=2852","title":{"rendered":"Scheduling Transfer Files via FTP\/SFTP use WinSCP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In some cases, your company needs to transfer several secret\/sensitive data either to your customer\/3rd party vendor. But, due to the routines and massive data which need to be delivered, there must be an operator to do such kind of task whereby this situation is really frustrating for them as supposed to be done via simple script which I&#8217;ll explain in next few words.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also please bare in mind some security concern might be in place due to nowadays it is very not recommended for us to transmit something over internet without security header. It will lead your data into compromise by hacker and potentially will be misused.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Off to the topic.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this case I&#8217;d like to explain a little bit about two components that we are going to use.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>FileZilla Server: this software allows you to activate file server feature over FTP\/SFTP. You may configure in your file server located on the DMZ\/Perimeter zone. Also just open the necessary port as requested and use the <a rel=\"noreferrer noopener\" href=\"https:\/\/rachmadona.net\/error-listing-directory-winscp-filezilla\/\" target=\"_blank\">passive mode<\/a><\/li><li>WinSCP: this is a software for FTP client; you can use to get\/send the files to your FTP\/SFTP server. I used to try with FileZilla client but unfortunately it doesn&#8217;t come up with scheduling feature that&#8217;s why I recommend this software instead<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Ok, assuming that you&#8217;ve already had the FTP\/SFTP server configured properly. If not, you may take a look charm trick to do <a rel=\"noreferrer noopener\" href=\"https:\/\/rachmadona.net\/error-listing-directory-winscp-filezilla\/\" target=\"_blank\">here<\/a>. So, now you need to install WinSCP on your laptop\/pc. Once done, create a simple script .bat file as below:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>@echo off<br>\"C:\\Program Files (x86)\\WinSCP\\WinSCP.com\" ^<br>\/log=\"C:\\temp\\log\\winscp.log\" \/ini=nul ^<br>\/command ^<br>\"open ftpes:\/\/<strong><em>username:password@xxx.yourdomain.yyy:port<\/em><\/strong>\/\" ^<br>\"put <strong><em>C:\\temp\\transfer<\/em><\/strong> \/\" ^<br>\"exit\"<br>del \/s \/q \"<strong><em>C:\\temp\\transfer<\/em><\/strong>*.*\"<br>set WINSCP_RESULT=%ERRORLEVEL%<br>if %WINSCP_RESULT% equ 0 (<br>echo Success<br>) else (<br>echo Error<br>)<br>exit \/b %WINSCP_RESULT%<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Legend:<br>Username: put your username here which you&#8217;ve created on your FTP server<br>Password: put your password<br>xxx.yourdomain.yyy: target URL\/IP of your FTP server<br>Port: what port that you are using for FTP communication<br><code><strong><em>C:\\temp\\transfer<\/em><\/strong><\/code>&#8220;: location of the files that you desire to transfer<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition above script will also delete once the transfer is completed. Then now you need to save above script and put with &#8220;.bat&#8221; extension file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve already put the script with filename: transfer_winscp.bat located on c:\\temp and also some files on c:\\temp\\transfer<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-1.png\" alt=\"\" class=\"wp-image-2854\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-2.png\" alt=\"\" class=\"wp-image-2855\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s go to task scheduler and make a job schedule to transfer these files.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-3.png\" alt=\"\" class=\"wp-image-2856\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I created basic task with name: transfer files.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-4.png\" alt=\"\" class=\"wp-image-2857\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-5.png\" alt=\"\" class=\"wp-image-2858\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I chose daily and will always start on 10AM.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-6.png\" alt=\"\" class=\"wp-image-2859\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Select start a program and point to the script we&#8217;ve built.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-7.png\" alt=\"\" class=\"wp-image-2860\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-8.png\" alt=\"\" class=\"wp-image-2861\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">See the recap and you are good to go.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-9.png\" alt=\"\" class=\"wp-image-2862\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">An additional useful tips: if you want to run the script without any intervention and requires you to logon then you might need to activate above options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start the schedule manually:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-10.png\" alt=\"\" class=\"wp-image-2863\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As seen above the script is working as expected and the files have been transferred successfully.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/rachmadona.net\/wp-content\/uploads\/2020\/06\/image-11.png\" alt=\"\" class=\"wp-image-2864\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">No more files left on the directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s all. Hope this information useful for you to setup proper script to transfer files automatically using FTP\/SFTP server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In some cases, your company needs to transfer several secret\/sensitive data either to your customer\/3rd party vendor. But, due to the routines and massive data which need to be delivered, there must be an operator to do such kind of task whereby this situation is really frustrating for them as supposed to be done via&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,27],"tags":[73,178,190,191,508],"class_list":["post-2852","post","type-post","status-publish","format-standard","hentry","category-tips-trick","category-windows","tag-automatic-transfer-file","tag-filezilla","tag-ftp-client","tag-ftp-server","tag-winscp"],"_links":{"self":[{"href":"https:\/\/rachmadona.net\/index.php?rest_route=\/wp\/v2\/posts\/2852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rachmadona.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rachmadona.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rachmadona.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/rachmadona.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2852"}],"version-history":[{"count":0,"href":"https:\/\/rachmadona.net\/index.php?rest_route=\/wp\/v2\/posts\/2852\/revisions"}],"wp:attachment":[{"href":"https:\/\/rachmadona.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rachmadona.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rachmadona.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}