How can I use rsync to sync only new and updated files?

0
21
Asked By EpicGamer42 On

I'm trying to sync my local drive with an external hard drive using rsync and I want it to only copy new and updated files. Additionally, I need it to remove files from the destination if they've been removed from the source. I initially used the `-avP` command but it seems to copy everything again, which makes the process much longer than I would like. I'm using Debian 13 for this backup. How should I structure my command to achieve the desired incremental backup?

4 Answers

Answered By BackupPro99 On

If you're seeing everything copied again, it might be due to differences in file permissions or timestamps. Use the same path formatting on both sides, including trailing slashes. Try `rsync -avhsP --delete /source/path/ /destination/path/` and consider running it with a dry-run using the `--dry-run` option first to verify it will do what you expect.

Answered By SystemGuru_74 On

Just a tip: If you have a large amount of data to transfer, including exclusions for items like your system's trash can can save you some time. For example, you might do `rsync -avhsP --delete --exclude=.Trash-1000 /mnt/media/ acer3:/mnt/media/`.

Answered By CodeWizard_92 On

You can simplify your command to `rsync -av --delete /path/to/source/ /path/to/destination/`. This way, it will only copy new or updated files from the source and also remove files from the destination that no longer exist in the source.

Answered By LinuxLover_88 On

Make sure you use the `-u` option as well, which tells rsync to skip files that are newer on the destination. It's a good way to ensure you're only syncing what's necessary.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.