Rsync backup remove deleted files




















To do this you simply add the --delete option to rsync. You will be prompted for your password on the remote host before the copy starts. If your user name is different on the remotehost than on the computer you are running rsync, then you need to specify username remotehost rather than just remotehost. If you are using rsync from a remote site outside MGH, please use the gateway server door. Please check out the man page for other examples of rsync usage and how to use more advanced options.

Group Permissions With the -a option the rsync will try to preserve both the exact permissions and group of the source. So on these machines you can just run: rsync -aZP The key rule here to remember is use the -Z option when you are rsyncing files INTO your group storage areas Other common options you may which to use: -H. Jayen Jayen 1, 3 3 gold badges 15 15 silver badges 27 27 bronze badges.

I keep weekly snapshots going back almost a year and daily ones for a month which take up surprisingly little space. I'd probably use rsnapshot but my scripts were started, some years ago, before that existed in a stable form.

Stefan Stefan 1 1 1 bronze badge. Prabath Dolawatta Prabath Dolawatta 1 1 gold badge 5 5 silver badges 13 13 bronze badges. I think the aim was to keep files that have been deleted for a week, as a backup where deleted files are removed immediately isn't that much use.

This seems to still remove any deleted files immediately, and then go and delete anything that hasn't been used for 7 days on top which is even worse. This script is hella dangerous. If rsync fails in your example, it'll delete things anyway. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Community Bot 1.

Ganesh Ghube Ganesh Ghube 79 1 1 silver badge 1 1 bronze badge. I think -W makes it not to copy only incremental data but to always copy whole files.

I got this error by executing this command: rsync: Failed to exec --delete-before: No such file or directory 2 — Jeff Tian. That means it takes care to synchronize local and remote such that files added in local are added to remote files removed from local are removed from remote files added in remote are removed files removed from remote are restored from local if they exist, else ignored The parameters explained: -a archive mode -v increase verbosity -h output numbers in a human-readable format -n dry run, perform a trial run with no changes made.

Always use this flag initially to prevent data loss. When you are happy, remove it. This is why it is important to address rsync errors. Lonnie Best Lonnie Best 1, 2 2 gold badges 25 25 silver badges 36 36 bronze badges. Thanks for the tip! I am the original author of this question 5 years ago.

I'm really glad you posted this, cuz I have been planning to set up syncing to an NTFS drive in the near future, and I probably would have run into the permissions error because I was planning to use the "-a" option for rsync, which syncs permissions among other things. So I added "--no-perms" to my notes. I now plan to use rsync -a --no-perms --delete-before. I have a question: Wouldn't --delete-before avoid problems with file deletion by running the deletion before the sync?

Thought that was its purpose. I guess it would depend on how early it really "deletes before". If it some how encounters one error before the deleting begins, your screwed. My advice to you is to avoid NTFS anytime you can unless you like sharp pains in your ass :.

NTFS to Linix works fine. Avoid "Linux file system" to "Non-Linux File System"; it is too much of a pain to ensure deleting works right. Mitchell Guerrero Mitchell Guerrero 17 1 1 bronze badge. Are you sure that you don't need two -- in front of --delete? And why do you think the position of this delete option has to appear after the directories?

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. B Layer B Layer 4, 1 1 gold badge 11 11 silver badges 28 28 bronze badges. Hmm, maybe --ignore-errors is the ticket. Invariably, rsync runs in to some sort of error with a file disappearing before it can be copied or a gvfs mount point that can't be read by root.

I'll try adding that flag and see what happens. Yep, --ignore-errors was the ticket. I found, as Gringo Suave said above as a comment, that wildcards were my issue. I had to use --dry-run and figure out how to rid the wildcard before --delete could work. I think "wildcards can be problematic with rsync" is a bit misleading as it implies there's something tricky about rsync's handling of wildcards.

The thing is, rsync doesn't handle them. That's what the shell is for. So make sure each wildcard is visible to the shell i. Then it should be easy to reason about what will happen in rsync, e. You've leveled up your "rsync fu", then. Show 1 more comment. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password.



0コメント

  • 1000 / 1000