Use Rsync To Save Your Life
HTML-код
- Опубликовано: 6 фев 2025
- Here are the basics of how to use Rsync to back up your computer.
👇 PULL IT DOWN FOR THE GOOD STUFF 👇
Patreon - / thelinuxcast
Liberapay - liberapay.com/...
RUclips - / @thelinuxcast
===== Follow us 🐧🐧 ======
Discord - / discord
Odysee - odysee.com/$/i...
/ thelinuxcast
/ mtwb
Mastodon- fosstodon.org/...
gitlab.com/the...
Subscribe at thelinuxcast.org
Contact us email@thelinuxcast.org
Telegram Group - t.me/+9lYoIuLh...
Amazon Wishlist - www.amazon.com...
Merch Store - zaney.creator-...
Logo Courtesy of - pedropaulo.net
==== Special Thanks to Our Patrons! ====
thelinuxcast.o...
==== Referenced ====
#tut #rsync #thelinuxcast - Наука
One notable flag everyone should know is -n, which has rsync do a dry run (i.e. it doesn't actually do any copying or deleting, it shows you what would happen if you ran the command without that flag). Probably good to do it at least on your first run of the script so you can see if you made any mistakes in the destination or forgot to exclude something.
rsync already transfers only the deltas of the files to the destination (unless you're using a fresh destination directory every time, in which case it will obviously copy the entire file again). What the --delete option does is match the destination dir with the source dir by deleting files that are present in the destination but not in the source. You can also use --delete-before or --delete-after so this operation takes place respectively to the file sync
For example if you're rsyncing a website's files, you probably want to use --delete-after so that the users don't bump into any missing files while you are copying stuff
Thanks for pointing that out
Another important flag is -z, which compresses files for rsynching transfers to a remote destination (and decompresses them upon arrival). Saves a lot of network traffic. At my last job (network admin at a small college), I used a script called rsnapshot, which did (very granularly configuarable) scheduled backups of a substantial amount of system, faculty, staff, and student data in near real time. (The previously existing backup system would not complete before the next scheduled time, except overnight.) Saved a bunch of network resources, time, and backup media capacity.
I was very diligent in backing up my data, did it often, stored them in several places (including off-site). Sadly, the backup program I used didn't properly restore, and the files it had created were so obscure I couldn't even find where the problem was.... So - check that you can restore.
rsync works great in that regard. Finally found something that works, where I can restore as well as back up...
Always a good idea to write a script for commonly used commands. That way you don't mistype things later on. I've got a bunch of those myself, ranging from just checking the CPU temperature to backing up all of my files. I also have a bunch of shell functions and variables I put into ~/.bash_aliases for doing daily tasks. My favorite is still `lrt` which does something akin to `ls -rt | tail` but with columns.
Awesome video Matt. I also add -h for human readable and the --progress, to see the file information like size and the like.
I did a video called " Save the Music" showing a bit about my rsync script from Joe Collins.
Yes that --delete switch is like the "dd" command, it will have everything deleted before ya know what is happening and it is way past to late to do anything so use with Caution!
Thanks Matt!
LLAP 🖖
One could use the --dry-run flag to test everything before doing the real thing... 🙂
Using the -a & -A (Double-A) options will give one a more complete copy.
A BACKUP is with just the Double-As.
A MIRROR to the target is with the Double-As and the - -delete option.
A SYNC is a BACKUP in one direction, then a BACKUP in the other. Careful.
Another great video, dude. Thanks for sharing.
my understanding of the --delete option is a little different. i'm fairly sure that it just deletes any files at the receiving directory that are not in the source directory. what you describe as it only transferring files that have been changed or added since the last sync i'm fairly sure is just the default functionality of rsync.
i'm a bit new to this so i may be wrong, but that seems to be backed up based on a few different things i've read across the web.
@@squishy-tomato it does help get rid of system clutter and keeping your shizzle clean and up to date though.
Exactly: it "syncs" including deleting if not existing at the source.
You are totally right
Thanks for making this video. Rsync gives me options paralysis.
A cleaner way to use --exclude:
--exclude={"item1","item2","etc..."}
You might find it easier to keep your excludes in a file and use the --exclude-from=$EXCLUDE option.
that's what he meant to do, he has a variable for the exclude file's path 12:20, but for some reason he couldn't get it to work, I remember i did use the exclude file without any problem
--delete
What dose not exist in source, will be deleted in Destination.
But be carful if you sychronize p.e. from HD and to the same Destination from an usb witch holds only a few of the files.
Lets say you have hunderts files saved with rsync. Then you have a copy of one file with you on USB. After changing this file you want to synchronize only this one file from the USB - never use --delete - therefore you delete all files in your backup and hold only one file.
So be careful and dry it out before with --dry-run together with - v for verbose.
It sow you before what it will do.
To delete the source after it saved, I believe you can use --remove-sorce-files.
Greetings Sven
I use rsync to back up /boot. /boot just is not covered by my BTRFS subvolumes. In fact, if you’re not using BTRFS, Timeshift uses rsync under the hood. I just do BTRFS manually (though with custom scripts) so that I have full control and full ability to leverage BTRFS for system recovery.
I do the same. I have a small script with a menu calling Timeshift to --create --delete --list etc.
and automatically do a "grub-mkconfig" so I can recover right from GRUB menu if need be.
Love you Matt. Finally gonna use rsync to backup nextcloud
I use btrfs-send to save and backup snapshots of my home directory.
Btrfs is the best backup software I've had since time machine on MacOS 15 years old.
hi, nice video about one of the most important commands (utlis) ever. But what i did not really understand, is the explanation of the --delete flag. It just deletes files in destination folder as they are deleted in source folder, that's all. It has nothing to do with the incremental transfers, as rsync does this by default, w/o the --delete flag. thx for this vid.
Yeah I'm really bad at explaining that command.
I do actually delete files every now and then and get annoyed when my system clutters with things I already tried to delete.
I've found grsync useful to get started and easily helps get the paths
thank you!
tar and rsync have always been my go to for minor backups. Full disk images are done with clonezilla
Personally I prefer rclone in a lot of cases, especially for sending things offsite. But sometimes rsync works better, especially for larger files.
Good work man! Tnx!
Matt, what is the difference into your "-a" and the "-A" on settings? By the way, what is "-rlptgoD (no -A,-X,-U,-N,-H)", it seems a futuristic language for me...
--archive, -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
--acls, -A preserve ACLs (implies --perms)
I would expect caps A for keeping the permissions (--perms).
so -a is an combination of several flags. Basically, -A is just one of those flags. You'd use -A if you just wanted to preserve permissions, and nothing else. -a also preserves symlinks and a while hose of other properties.
Thank you.
What would be a command to backup dir1 to dir2, and only transfer the ones with a newer modification date or files which don't exist in dir2?
Can rsync be used to create differential backups of a boot disk? It seems like it just backs up files, and directories.
what different between --delete and -P?
I should take another look at rsync. I am using rclone for my backups to pCloud. I got tired of their client messing things up. Rclone is a great way to access Dropbox type sites.
I might have to look at that because I use pcloud too.
@@TheLinuxCast Would be worth it Matt. There are few videos about on rclone. Chris Titus has done one but it was a bit rushed and difficult to follow without reference to the documentation on the rclone website to track down how he configured the cloud backend to encrypt files.
One useful feature of rclone is that it can mount the cloud filesystem as a local directory.
I would like to use it to backup my whole OS to a external harddrive and then backup whenever I want, how can I do that? Just "rsync -av / /media/flashdrive" ?
Dude, take a look at and do an episode on syncthing…
rsync with hardlinks is the best backup solution IMHO
Would you set up a local NAS?
Someday that'd be nice
Cheers
isn't using a gui like timeshift way easier ? it just runs rsync right....
rsync -av --delete /source /destination may be considered way more easy by some. Moreover, timeshift is as such not designed as a backup tool for user data.
So you do not like timeshift? Not using BTRFS?
Fedora uses some odd subvolume layout which timeshift doesn't like.
@@TheLinuxCast Yeah it's a pain in the arse just to get it to work right. All because of @ causing problems. Ever thought about making a video getting Timeshift to work right on Fedora? I know you love Rsync, but something many do not know to get snapshots to work right.
@@feelsbad1193 I'm going to do some btrfs videos, I've just not decided on how to do them.
@@TheLinuxCast oh there is my answer. Interesting, sk can't fadora devs patch it or do timeshift devs have to work for a new requirement 🤔
Can you make a video how to use your dotfile for install new linux. Like i want to install minimun debian with your i3 and other config? Thank you so much
After fedora 34 it stopped working.
Rsync works for me on 36 or did you mean something else?
If you like rsync, you’ll like Rclone as well. Rclone Is the rsync for cloud storage. YW!!
GVM.
Hello Matt youtube have done it again! One of our community members :switch to Linux has been banned from RUclips for promoting media players. Please spread the word,🙏
SwitchedtoLinux seems to be still there? I can access his videos.
@@sunriseleatherco.6587 He can't upload videos he got a strike
Do you have pcloud? Liking it? Planning to host ripped movies. Would that be good?
Matt I went so far as to alias cp to rsync -auh --progress.
Now that is an interesting way to use it