Use Rsync To Save Your Life

preview_player
Показать описание
Here are the basics of how to use Rsync to back up your computer.
👇 PULL IT DOWN FOR THE GOOD STUFF 👇

===== Follow us 🐧🐧 ======

==== Special Thanks to Our Patrons! ====

==== 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.

afroceltduck
Автор

Another great video, dude. Thanks for sharing.

trevorflux
Автор

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

Flackon
Автор

You might find it easier to keep your excludes in a file and use the --exclude-from=$EXCLUDE option.

topherfungus
Автор

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... 🙂

Bruces-Eclectic-World
Автор

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.

burnt_
Автор

A cleaner way to use --exclude:

--exclude={"item1", "item2", "etc..."}

Miguel_GM
Автор

--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

svenwindpassinger
Автор

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.

VoltVandal
Автор

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.

anon_y_mousse
Автор

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.

bobpotter
Автор

I use btrfs-send to save and backup snapshots of my home directory.

nevoyu
Автор

I do actually delete files every now and then and get annoyed when my system clutters with things I already tried to delete.

smotheredbyPrincessPeach
Автор

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.

OcteractSG
Автор

Personally I prefer rclone in a lot of cases, especially for sending things offsite. But sometimes rsync works better, especially for larger files.

npaladin
Автор

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" ?

ursodopudim
Автор

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).

LisandroCarmona
Автор

tar and rsync have always been my go to for minor backups. Full disk images are done with clonezilla

Chris-ipuv
Автор

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?

FreezingFroggie
Автор

Can rsync be used to create differential backups of a boot disk? It seems like it just backs up files, and directories.

middle_pickup