A Blog Of Random Coding Techniques & Experiments Robert Askam

How to move files from Server to Windows with Cygwin and Rsync Post How to move files from Server to Windows with Cygwin and Rsync 1 year ago

This guide will show you how to move files from a Linux server to a windows folder and delete the files after the download. Using rsync and Cygwin.

Cygwin

Download Cygwin and follow these steps:

Step 1

Accept the Root Directory of C:\cygwin and Install For All Users. Default Text File Type is Unix / binary.

Step 2

Accept the default Local Package Directory, which is the Windows desktop of the notebook PC. This will enable you to easily put a cygwin icon on the Windows desktop.

Step 3

Select Direct Connection if directly connected to the Internet or connected through a transparent router.

Step 4

Pick one of the Available Download Sites.

Step 5

Maximize the Cygwin Setup window to see more. Click on Net. Scroll down to openssh and select it to install it. Also select rsync. Next click on Shells, and select bash if it is not already selected.

Step 6

Press the Next button at the lower right corner of the screen. The setup and installation of Cygwin will begin.

Step 7

Setup is complete. Check Create icon on Desktop, then press finish. The cygwin icon will appear on your desktop.

Putty

Run this command on the folder you want to search using Putty to find anything over 380 days and create file rsyncfiles.
find /data/images -type d -mtime +380 > /data/rsyncfiles

SFTP

SFTP into the data drive and copy the rsyncfiles folder to desktop.

Move and Delete

Create a folder on Desktop called images.In the cygwin run from desktop
rsync -ravHPx --dry-run --delete-during --files-from=rsyncfiles [user]@[IP]:/ images/
To just delete the files not the Directory
rsync -ravHPx --remove-source-files --files-from=rsyncfiles [user]@[IP]:/ images/

Notes

To search for NOT empty Directories
find . -mindepth 1 -maxdepth 1 -not -empty -type d -exec ls -rt "{}" +;