I have an iBasso digital music player and I need a little help uisng rsync. I want to copy all of my muisc from /home/garrett/Music/ into my SD card which is at /media/garrett/6BF6-AC8A/ I'm currently using the command rsync -a --delete /home/garrett/Music/ /media/garrett/6BF6-AC8A/ The thing is I would also like to transfer my audio books which I don't keep in my music directory, they are in /home/garrett/Audiobooks/ I would like to add the audiobooks direcotry to the command above but instead of only coping the contents of the Audiobooks directory the way it's doing with my Music directory I would like it to copy the directory itself and it's contents, not just the contents. Secondly how do I keep the command listed above from deleting the Audiobook DIR everytime it runs, I need it to make an exception for the Audiobooks DIR. Thanks.

I believe that you should be able to create a symbolic link within your home Music directory that points to your Audiobooks directory. Then, you can run the rsync command on the Music directory and get both directories sync'ed at the same time. When running the reverse rsync command (from SD to home) you'll have to pass the -K or --keep-dirlinks option so that rsync doesn't destroy the symlink in the home Music folder to replace it with an actual directory, and instead it will follow the link and sync the SD's Audiobooks subfolder with your home's Audiobooks folder.

If you don't want to keep the symlink in your home Music folder, you could just write a simple bash script that creates the symlink, then runs rsync, and then removes the symlink right after. You can create a similar script on the SD card for when doing the reverse operation.

I'm not 100% sure that this will work, but it's worth a try (preferrable, test it with some "test" directories first, to make sure you don't lose your data if something goes wrong).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.