| ascp: Transferring from the Command Line with Ascp |
116
•
Transfer random data and do not save result to disk (no source or destination storage required)
Transfer 10 MB of random data from 10.0.0.2 as user
root
and do not save result to disk:
#ascp --mode=send --user=root --host=10.0.0.2 faux:///dummy?10m faux://
Ascp File Manipulation Examples
Ascp can manipulate files and directories as part of the transfer, such as upload only the files in the specified source
directory but not the directory itself, create a destination directory, and move or delete source files after they are
transferred.
•
Upload a directory
Upload the directory
/data/
to the server at 10.0.0.1, and place it in the
/storage/
directory on the server:
# ascp /src/data/ root@10.0.0.1:/storage/
•
Upload only the contents of a directory (not the directory itself) by using the
--src-base
option:
Upload only the contents of
/data/
to the
/storage/
directory at the destination. Strip the
/src/data/
portion of the source path and preserve the remainder of the file structure at the destination:
# ascp --src-base=/src/data/ /src/data/ root@10.0.0.1:/storage/
•
Upload a directory and its contents to a new directory by using the
-d
option
.
Upload the
/data/
directory to the server and if it doesn't already exist, create the new folder
/storage2/
to
contain it, resulting in
/storage2/data/
at the destination.
# ascp -d /src/data/ root@10.0.0.1:/storage2/
•
Upload the contents of a directory, but not the directory itself, by using the
--src-base
option
:
Upload all folders and files in the
/clips/out/
folder, but not the
out/
folder itself, to the
/in/
folder at the
destination.
# ascp -d --src-base=/clips/out/ /clips/out/ root@10.0.0.1:/in/
Result: The source folders and their content appear in the
in
directory at the destination:
Source
/clips/out/file1
/clips/out/folderA/file2
/clips/out/folderB/file3
Destination
/in/file1
/in/folderA/file2
/in/folderB/file3
Destination without --src-base
/in/out/file1
/in/out/folderA/file2
/in/out/folderB/file3
Without
--src-base
, the example command transfers not only the contents of the
out/
folder, but the folder
itself.
Note:
Sources located outside the source base are not transferred. No errors or warnings are issued, but the
skipped files are logged. For example, if
/clips/file4
were included in the above example sources, it would
not be transferred because it is located outside the specified source base,
/clips/out/
.
•
Upload only the contents of a file and a directory to a new directory by using
--src-base