ascp: Transferring from the Command Line |
Below are examples of using the ascp command to manipulate files. In each example, the client is the local computer and the server is the remote computer.
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 /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 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 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 |
Destination (docroot) |
Destination without --src-base |
Without --src-base, the example command transfers not only the contents of the out/ folder, but the folder itself.
Upload a file, /monday/file1, and a directory, /tuesday/*, to the /storage/ directory on the server, while stripping the srcbase path and preserving the rest of the file structure. The content is saved as /storage/monday/file1and /storage/tuesday/* on the server.
# ascp --src-base=/data/content /data/content/monday/file1 /data/content/tuesday/ root@10.0.0.1:/storage
Download a file, /monday/file1, and a directory, /tuesday/*, from the server, while stripping the srcbase path and preserving the rest of the file structure. The content is saved as /data/monday/file1 and /data/tuesday/* on the client.
# ascp --src-base=/storage/content root@10.0.0.1:/storage/content/monday/file1 root@10.0.0.1:/storage/content/tuesday/ /data
Uploadfile0012 to Pat's docroot on the server at 10.0.0.1, and move (not copy) the file from C:/Users/Pat/srcdir/ to C:/Users/Pat/Archive on the client.
# ascp --move-after-transfer=C:/Users/Pat/Archive C:/Users/Pat/srcdir/file0012 Pat@10.0.0.1:/
Download srcdir from the server to C:/Users/Pat on the client, and move (not copy) srcdir to the archive directory /Archive on the server.
# ascp --move-after-transfer=Archive Pat@10.0.0.1:/srcdir C:/Users/Pat
Upload file0012 to Pat's docroot on the server at 10.0.0.1, and save it as /srcdir/file0012 (stripped of C:/Users/Pat). Also move file0012 from C:/Users/Pat/srcdir/ to C:/Users/Pat/Archive on the client, where it is saved as C:/Users/Pat/Archive/srcdir/file0012.
# ascp --src-base=C:/Users/Pat --move-after-transfer=C:/Users/Pat/Archive C:/Users/Pat/srcdir/file0012 Pat@10.0.0.1:/
Upload /content/ to the server, then delete its contents (excluding partial files) and any empty directories on the client.
# ascp -k2 -E "*.partial" --remove-after-transfer --remove-empty-directories /data/content root@10.0.0.1:/storage
Upload /content/ to the server, while stripping the srcbase path and preserving the rest of the file structure. The content is saved as /storage/* on the server. On the client, the contents of /content/, including empty directories but excluding partial files, are deleted.
# ascp -k2 -E "*.partial" --src-base=/data/content --remove-after-transfer --remove-empty-directories /data/content root@10.0.0.1:/storage