0

I've been messing with rsync to push my music library (managed by banshee) to my sdcard, which I use for my phone.

This helps me get around the fact that I don't have a good GUI program to sync music back and forth from my phone. While I always hated iTunes, I'll admit, it was great at managing music and other files stored in the program between an external device and the PC. I don't claim that rsync isn't an amazing utility, I know it is, I'm just not as skilled with it as I hoped to be.

Going through the man page a couple of times I came up with the following 2 scripts:

syncToSdCard.sh:

#!/bin/bash
exec >  >(tee ~/rsync.out);
exec 2> >(tee ~/rsync.err);

rsync -v -r --delete-delay /home/user/Music/ /media/user/0741-C987/Music/;

updateSdCardOnly.sh

#!/bin/bash
exec >  >(tee ~/rsync.out);
exec 2> >(tee ~/rsync.err);

rsync -v -r -u --inplace -m --prune-empty-dirs -e --delete /home/user/Music/ /media/user/0741-C987/Music/;

My goal is to both update the directory on the sdcard with the contents of the directory on my machine, and clean anything that has been moved or removed from the source directory.

The first rsync script (syncToSdCard.sh) does this; however, it takes a long time to run.

The second rsync script, while it contains the delete option only pushes changes from my local machine (new files and updated files) to the sdcard; this script is extremely fast though.

What I'm looking for is someone who can help me merge the 2 together, to get a fast update with deletion of files that no longer exist on the source (pc) as they do on the target (sdcard).

Can someone please help me with this? I'm also open to alternative ways of achieving the same goal if possible; rsync is just the best utility I can think of for this kind of operation.

Thanks.

1 Answer 1

0

I think I found the answer to my question. I was messing around with more parameters, more or less, trying to combine the 2 scripts and came up with the following:

#!/bin/bash
exec >  >(tee ~/rsync.out);
exec 2> >(tee ~/rsync.err);

rsync -v -r -u --inplace -m --prune-empty-dirs --delete-delay /home/user/Music/ /media/user/0741-C987/Music/;

So far, it has done what I've been looking for successfully, it builds a list of specific changes of what needs to get pushed to the device and does so without doing a slow comparison on each file, then follows with a fast delete.

I won't mark this as complete yet, until I've tested it a few more times to verify that it is exactly what I'm looking for.

If anyone else does indeed know a better way to achieve this result than by doing what I came up with here, please let me know!

Thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .