Last active
October 31, 2016 11:58
-
-
Save chrisbraddock/46ecdb013dc5db19b8d4 to your computer and use it in GitHub Desktop.
transfer large amount of files - e.g. a large multi-terabyte directory with many subdirectories between physical drives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -f If the destination file cannot be opened, remove it and create a new file, without | |
# prompting for confirmation regardless of its permissions. (The -f option overrides | |
# any previous -n option.) | |
# -p Cause cp to preserve the following attributes of each source file in the copy: mod- | |
# ification time, access time, file flags, file mode, user ID, and group ID, as | |
# allowed by permissions. Access Control Lists (ACLs) and Extended Attributes (EAs), | |
# including resource forks, will also be preserved. | |
# | |
# If the user ID and group ID cannot be preserved, no error message is displayed and | |
# the exit value is not altered. | |
# | |
# If the source file has its set-user-ID bit on and the user ID cannot be preserved, | |
# the set-user-ID bit is not preserved in the copy's permissions. If the source file | |
# has its set-group-ID bit on and the group ID cannot be preserved, the set-group-ID | |
# bit is not preserved in the copy's permissions. If the source file has both its | |
# set-user-ID and set-group-ID bits on, and either the user ID or group ID cannot be | |
# preserved, neither the set-user-ID nor set-group-ID bits are preserved in the | |
# copy's permissions. | |
# | |
# -R If source_file designates a directory, cp copies the directory and the entire sub- | |
# tree connected at that point. If the source_file ends in a /, the contents of the | |
# directory are copied rather than the directory itself. This option also causes | |
# symbolic links to be copied, rather than indirected through, and for cp to create | |
# special files rather than copying them as normal files. Created directories have | |
# the same mode as the corresponding source directory, unmodified by the process' | |
# umask. | |
# | |
# In -R mode, cp will continue copying even if errors are detected. | |
# | |
# Note that cp copies hard-linked files as separate files. If you need to preserve | |
# hard links, consider using tar(1), cpio(1), or pax(1) instead. | |
# | |
# -v Cause cp to be verbose, showing files as they are copied. | |
# | |
# per: http://stackoverflow.com/a/5345078/227260 | |
# 2>&1 to redirect STDOUT AND STDERR to the file (works in bash, zsh) | |
echo "running large-xfer.sh" >> large-xfer.log | |
function doCopy() { | |
cp -f -p -R -v $1 $2 >> large-xfer.log 2>&1 | |
} | |
function doMove() { | |
mv -f -p -R -v $1 $2 >> large-xfer.log 2>&1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment