I have a list of (a couple thousand) absolute paths to files on a remote server that I need to download to my PC.
I also need the files to keep the directory structure intact for those files.
Example:
/* UNIX Server File-System */
/home/username/
stuff/
more-stuff/
data/
file1.txt
/* Local Windows File-System After Transfer */
C:\Users\username\Documents\home\username\
stuff\
more-stuff\
data\
file1.txt
Ideally, I would use some type of FTP to get those files to my PC. However, I am unaware of a program or CLI command that supports getting a list of files. I need to get specific files from specific directories, I can't just download whole directories.
My Question: How can I use a list of absolute paths to automatically download the files to my localhost? (while keeping the directory structure intact)
Additionally, I have these files in a PHP array. So it is possible for me to export the list as JSON, CSV, XML, etc.
Best Answer
If you mind you can use
rsync
with something likewhere in
/path/yourlist.txt
you can put your list of files with the full path/
The path to add to the filename in your list (If they are full pathname/
)remote:/backup
the remote host name and its relative pathYou can read more searching for
--files-from
from theman rsync
[1]... in the man page there is more...