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
  • НаукаНаука

Комментарии • 64

  • @afroceltduck
    @afroceltduck 2 года назад +27

    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.

  • @Flackon
    @Flackon 2 года назад +15

    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

  • @bobpotter6430
    @bobpotter6430 2 года назад +3

    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.

  • @baruchben-david4196
    @baruchben-david4196 Год назад +2

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

  • @anon_y_mousse
    @anon_y_mousse 2 года назад +4

    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.

  • @Bruces-Eclectic-World
    @Bruces-Eclectic-World 2 года назад +10

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

  • @k.chriscaldwell4141
    @k.chriscaldwell4141 3 месяца назад

    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.

  • @trevorflux1049
    @trevorflux1049 2 года назад +1

    Another great video, dude. Thanks for sharing.

  • @burnt_666
    @burnt_666 2 года назад +19

    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.

    • @smotheredbyPrincessPeach
      @smotheredbyPrincessPeach 2 года назад

      @@squishy-tomato it does help get rid of system clutter and keeping your shizzle clean and up to date though.

    • @atom6_
      @atom6_ 2 года назад +1

      Exactly: it "syncs" including deleting if not existing at the source.

    • @OmarIskandarone
      @OmarIskandarone 2 года назад

      You are totally right

  • @icollided
    @icollided 29 дней назад

    Thanks for making this video. Rsync gives me options paralysis.

  • @Miguel_GM
    @Miguel_GM 2 года назад +7

    A cleaner way to use --exclude:
    --exclude={"item1","item2","etc..."}

  • @topherfungus8424
    @topherfungus8424 2 года назад +10

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

    • @mightycoderx
      @mightycoderx 5 месяцев назад

      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

  • @svenwindpassinger2170
    @svenwindpassinger2170 Год назад +2

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

  • @OcteractSG
    @OcteractSG 2 года назад +2

    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.

    • @Bob-1802
      @Bob-1802 2 года назад +1

      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.

  • @darthkielbasa
    @darthkielbasa Год назад

    Love you Matt. Finally gonna use rsync to backup nextcloud

  • @nevoyu
    @nevoyu 2 года назад +4

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

    • @yramagicman675
      @yramagicman675 2 года назад +1

      Btrfs is the best backup software I've had since time machine on MacOS 15 years old.

  • @VoltVandal
    @VoltVandal 2 года назад +2

    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.

    • @TheLinuxCast
      @TheLinuxCast  2 года назад

      Yeah I'm really bad at explaining that command.

  • @smotheredbyPrincessPeach
    @smotheredbyPrincessPeach 2 года назад +1

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

  • @davebean2886
    @davebean2886 2 года назад

    I've found grsync useful to get started and easily helps get the paths

  • @hiroshi976
    @hiroshi976 5 месяцев назад

    thank you!

  • @Chris-ip8uv
    @Chris-ip8uv 2 года назад +2

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

  • @npaladin2000
    @npaladin2000 2 года назад +1

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

  • @gavr1loo
    @gavr1loo Год назад

    Good work man! Tnx!

  • @LisandroCarmona
    @LisandroCarmona 2 года назад +1

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

    • @TheLinuxCast
      @TheLinuxCast  2 года назад

      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.

  • @kahnzo
    @kahnzo Год назад

    Thank you.

  • @FreezingFroggie
    @FreezingFroggie 6 месяцев назад

    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?

  • @middle_pickup
    @middle_pickup 5 месяцев назад

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

  • @sopojarwo3483
    @sopojarwo3483 Год назад

    what different between --delete and -P?

  • @donaldmickunas8552
    @donaldmickunas8552 2 года назад +1

    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.

    • @TheLinuxCast
      @TheLinuxCast  2 года назад +2

      I might have to look at that because I use pcloud too.

    • @keithmcgavin5396
      @keithmcgavin5396 2 года назад

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

  • @ursodopudim
    @ursodopudim 6 месяцев назад

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

  • @manwe_sulimo
    @manwe_sulimo 2 года назад +1

    Dude, take a look at and do an episode on syncthing…

  • @jwisemanm
    @jwisemanm Год назад

    rsync with hardlinks is the best backup solution IMHO

  • @wyfyj
    @wyfyj 2 года назад +1

    Would you set up a local NAS?

  • @Tech-Dev
    @Tech-Dev Год назад

    Cheers

  • @Gurj101
    @Gurj101 2 года назад

    isn't using a gui like timeshift way easier ? it just runs rsync right....

    • @vanadium4167
      @vanadium4167 2 года назад

      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.

  • @feelsbad1193
    @feelsbad1193 2 года назад +1

    So you do not like timeshift? Not using BTRFS?

    • @TheLinuxCast
      @TheLinuxCast  2 года назад +3

      Fedora uses some odd subvolume layout which timeshift doesn't like.

    • @feelsbad1193
      @feelsbad1193 2 года назад +1

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

    • @TheLinuxCast
      @TheLinuxCast  2 года назад

      @@feelsbad1193 I'm going to do some btrfs videos, I've just not decided on how to do them.

    • @Gurj101
      @Gurj101 2 года назад

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

  • @funnynews341
    @funnynews341 2 года назад +1

    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

  • @VE64RD
    @VE64RD 2 года назад

    After fedora 34 it stopped working.

    • @TheLinuxCast
      @TheLinuxCast  2 года назад

      Rsync works for me on 36 or did you mean something else?

  • @drumpf4all
    @drumpf4all 2 года назад +1

    If you like rsync, you’ll like Rclone as well. Rclone Is the rsync for cloud storage. YW!!

  • @itsfish8672
    @itsfish8672 2 года назад +1

    GVM.

  • @mrbaba4355
    @mrbaba4355 2 года назад +2

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

    • @sunriseleatherco.6587
      @sunriseleatherco.6587 2 года назад

      SwitchedtoLinux seems to be still there? I can access his videos.

    • @mrbaba4355
      @mrbaba4355 2 года назад

      @@sunriseleatherco.6587 He can't upload videos he got a strike

  • @sanjeev2003
    @sanjeev2003 2 года назад

    Do you have pcloud? Liking it? Planning to host ripped movies. Would that be good?

  • @CyperN077
    @CyperN077 2 года назад +1

    Matt I went so far as to alias cp to rsync -auh --progress.

    • @Chris-ip8uv
      @Chris-ip8uv 2 года назад

      Now that is an interesting way to use it