[Linux]#4 rsync

Clay Ryu's sound lab·2023년 12월 3일
0

Framework

목록 보기
36/48

In Ubuntu, you can merge two directories using the 'rsync' command. Here is the general format:

don't forget to add "/" at the last in the path if you want to copy files from the source directory not the directory itself.

sudo apt-get install rsync
# example
rsync -a /path/to/sourceDirectory/ /path/to/destinationDirectory/
# in real use
rsync -a /home/clay/userdata/symbolic-music-encoding/Symbolic-Music-Encoding/dataset/nb_events/events_SymphonyNetDataset/ /home/clay/userdata/symbolic-music-encoding/Symbolic-Music-Encoding/dataset/nb_events/events_SymphonyNetDataset_all/

There are several reasons why 'rsync' is often preferred over 'cp' for merging directories:

  1. Incremental Copy: 'rsync' copies only the differences between the source and destination directories, which can make it faster and more efficient for large directories or over network connections.
  2. Preserving File Attributes: With the '-a' (archive) option, 'rsync' preserves symbolic links, file permissions, user & group ownerships, and timestamps. 'cp' can also do this with the '-p' option, but 'rsync' does it by default with the '-a' option.
  3. Progress and Verbosity: 'rsync' has options to display the progress of the copy operation ('--progress') and to increase verbosity ('-v'), which can be useful for long operations or troubleshooting.
  4. Resume Capability: If the copy operation is interrupted, 'rsync' can resume where it left off, whereas 'cp' would need to start over.
    Remote Copy: 'rsync' can copy to/from remote servers using a syntax similar to 'scp'.

In short, while 'cp' is a powerful tool for simple copy operations, 'rsync' provides more control and efficiency, especially for larger or more complex copy tasks.

Remember, both commands can lead to data loss if not used carefully, so always double-check your commands and consider backing up important data before proceeding.

profile
chords & code // harmony with structure

0개의 댓글