Announcement

Collapse
No announcement yet.

Using btrfs backups on new install

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Using btrfs backups on new install

    I'm a little confused on how to use the backups of @ and @home on a new Kubuntu install. I have made backups on an external hard disk of my latest @ and @home subvolumes, each with the date, time and ro additions to the titles of each. I want to erase my Kubuntu 18.04 and change to Kubuntu 19.10, which I like a lot (tried it on QEMU VMM). I want to use the whole hard disk for this, as I do not use Windows anymore. How do I transfer the @ and @home subvolumes on my external HD to my new install? I know I have to do some renaming, but despite some research on this I haven't been able to deduce the exact sequence of commands I need to make. I have the BTRFS Subvolume Manager installed on Dolphin, if that's any help. What confuses me is that I don't know the difference between rolling back and replacing new @ and @home subvolumes with my backups. I don't want to mess this up, so I would appreciate any help someone could give me.

    #2
    One other question I forgot to put in: will the backup @ subvolume cause any problems in the new install if it replaces the new @ subvolume, which contains newer versions of the 18.04 programs?

    Comment


      #3
      it sounds to me , like you would just be turning your new install (19.10) back into 18.04 if the backups are in fact snapshots of the 18.04 system (@) and (@home)

      is that the case ?

      VINNY
      i7 4core HT 8MB L3 2.9GHz
      16GB RAM
      Nvidia GTX 860M 4GB RAM 1152 cuda cores

      Comment


        #4
        OK, this isn't hard at all but you might want to be a little precise about what exactly you're trying to do. If your goal is to install the subvolumes from your external drive to the new install and have them co-exist so you can boot either, then here's the steps:

        PARTITIONING:
        Before installing, on the new hard drive create a swap partition, your BTRFS partition, an EFI partition (if needed or wanted), an possibly a partition for Virtual machines (this is only required if you plan on using Dynamically Sized virtual drives vs. fixed size virtual drives).

        INSTALL 19.10:
        Run the installer and set your BTRFS partition as /. It will (should anyway) find the swap partition and use it automatically as well as the EFI partition if you made one properly. As you know, this will result in two subvolumes of @ and @home.

        MOUNT THE ROOT BTRFS FILE SYSTEM:
        Create a mount point for your root BTRFS file system and mount it there. I use "/mnt/subvol" and I enter the mount into fstab so I can more easily access it later for snapshots, etc. Simply edit /etc/fstab with kate and duplicate the mount line for / and the delete the "subvol" reference in the options. For example if your root mount line in fstab looks like:

        UUID=60834933-1e99-4d5c-922c-9abbc373e172 / btrfs noatime,space_cache,compress=lzo,autodefrag,subvol =@ 0 1

        Copy it, change the mount point and delete the subvol option so it looks like:

        UUID=60834933-1e99-4d5c-922c-9abbc373e172 /mnt/subvol btrfs noatime,space_cache,compress=lzo,autodefrag 0 1

        and finally, mount it.

        sudo mount /mnt/subvol


        RENAME THE SUBVOLUMES:
        I recommend renaming both the new and old subvolumes because it will make things much clearer down the road (think "memory jogger"). The requirement is multi-fold. You must rename the subvolumes but also anything that references them. Thankfully, this is just grub.cfg and fstab. I use something meaningful and as short as possible, like rename @ to @1910 and @home to @1910home.

        Here's some posts of mine to review on this topic:
        https://www.kubuntuforums.net/showth...tibooting+grub
        https://www.kubuntuforums.net/showth...tibooting+grub

        As the posts detail, you need only use the regular "mv" command to rename the subvolumes then edit fstab and the main boot stanza of grub.cfg. Then reboot and run update-grub. Make sure you have a bootable USB in case you flub the edit and can't boot. You can do the edits en masse using sed replace-in-place like this:

        sudo sed -i 's/@/@1910/g' grub.cfg

        repeat for fstab and @home

        Now reboot and cross your fingers! Once booted successfully run update-grub.

        INSTALL THE BACKUP SUBVOLUMES OF 18.04:
        Create a mount point and mount your external drive. You can just plug it in and let UDEV mount it, but then you might get wacky mount point naming and it bugs me. So I make my own:

        sudo mkdir /mnt/external
        sudo mount /dev/XXXX /mnt/external

        "XXXX" would be the device name and partition number. Run "dmesg" in a terminal when you plug it in to see where it landed on your system. Most likely it will be /dev/sdb1.

        Once mounted properly, simple backup the backups from the external drive to /mnt/subvol:

        sudo btrfs send /mnt/external/@ | sudo btrfs receive /mnt/subvol

        repeat for @home. Once they are both received, rename and edit the using the same process outlined above.

        GRUB AND BOOTING - MAKING IT WORK AND A NOTE:
        Unless they fixed it this go-round, os-prober doesn't find BTRFS installed subvolumes. Since your 18.04 backup has /boot/grub/grub.cfg in it, the easiest way to add it to grub is to make grub "see" the grub.cfg in 18.04. To do that, you need to edit /etc/grub.d/40_custom and add this:

        menuentry 'Kubuntu 18.04' --class kubuntu {
        insmod part_gpt
        insmod btrfs
        search --no-floppy --fs-uuid --set=root 60834933-1e99-4d5c-922c-9abbc373e172
        configfile /@1804/boot/grub/grub.cfg


        Obviously, use the correct options, UUID, and subvolume name for your system. I used "GPT" but you may use MSDOS if you're still using the older MBR partitioning and I assumed using @1804 for the older install. This will bring up the grub menu from 18.04 when you select it. IMO this is the best way to do this because grub changes it's grub.cfg at every kernel update. This method will keep both your grub.cfgs up to date and bootable.

        NOTE: Remember you have installed 19.10 so you are using GRUB from that install. If you decide to delete 19.10 BE SURE YOU RE-INSTALL GRUB FROM 18.04 BEFORE DELETING 19.10 or you will not be able to boot. This is as easy as booting to 18.04 and running "grub-install" but if you forget and delete 19.10 first, you'll be unhappy. Also, if you install another distro in this manner, it too will take over and install it's own grub.

        Let us know how it goes!


        EDIT: Another note: if you use GPT partitioning with GRUB it needs special space to install. Here's my How-To on this topic: https://www.kubuntuforums.net/showth...light=grub+gpt
        Last edited by oshunluvr; Oct 18, 2019, 04:48 PM.

        Please Read Me

        Comment


          #5
          I thought I was being precise but I guess I wasn't. All I really want to do is to have my home folder on 19.10 what it is now. I wasn't sure if the @ subvolume was necessary to copy as well. I thought it might not be, as I want to take advantage of the new 19.10 features. Last time I changed, from 16.04 to 18.04, I did a clean install and used Aptik to get all my home files. So I guess all I need to do is make sure the items from my 18.04 home folder are put into the new home folder. In other words, I don't want any co-existence--just one @ and one @home.

          Comment


            #6
            The @home subvolume holds everything that would normally be in your home folder. So all you really need to do is delete the @home from 1910 (or rename it to keep it for a while) then do the send|receive bit on @home from your external drive. You don't have to edit anything in that case, just reboot (or log out and remount /home and log back in). You will need to mount the root file system somewhere fir you can send @home in there.

            Please Read Me

            Comment


              #7
              OK, got it. So I guess that means that the previous @ (backup version) won't be necessary. Thanks for the help.

              Comment


                #8
                Another question. Re-reading the long post no. 4 I realize I'm not sure about re-naming. I assume that I leave both new subvolumes from 19.10, then send my backup @home file, which has date and time in the name, to /mnt, where my file system will be mounted. Can I just then use the mv command to transfer the contents of the backup file (now on /mnt/) to the empty @home subvolume generated by the 19.10 install? What would be the exact syntax of this? Presumably, after moving the contents of @home_backup to @home, I would delete the backup subvolume on /mnt/, and I'm done. Right? As for the new @ subvolume, I should just leave it alone and make up for whatever is missing, right? Do I have to do anything to Grub and fstab if I'm just filling the new @home subvolume with the backups?

                I get the feeling that I don't, but I want to be sure before I take the step of installing 19.10.

                Comment


                  #9
                  You're either over complicating the process a bit or you're asking for something I don't understand. You state "...to the empty @home subvolume generated by the 19.10 install...". So if it's empty, why transfer anything into it? Just delete it and copy the entire backup @home subvolume into the same location and you're done.

                  Now, I have assumed that when you stated "...my backup @home file..." you meant you used BTRFS send|receive to make a backup of your previous @home subvolume and it exists on the external drive as a subvolume on a BTRFS file system. If this is not the case, you will need to say exactly how your old home is stored. If you just copied the contents of in onto the external drive, then yes you will need to copy all the files into your new home. If it exists as a BRTFS backup file and not a subvolume (this is done using BTRFS send to a file) then you will need to restore it to a subvolume using BTRFS receive. If it exists as I have assumed - a full BTRFS subvolume backup - you will only need to send|receive it to the internal drive.

                  The method to restore varies with each of these cases so try and be very precise and detailed when you describe what you have and what you're trying to do.

                  I have assumed you want to use your previous home subvolume with your new install and you have made a backup of it to your external drive as a subvolume. To just do this you will not need to rename or edit anything.

                  Assumptions:
                  • The internal drive is sda and your BTRFS partition is the second partition so I will use sda2 to refer to the internal drive partition in my examples. Change sda2 to match your internal BTRFS partition.
                  • The external drive is sdb and the BTRFS partition is the first partition so I will use sdb1 to refer to the external drive partition in my examples. Change sdb1 to match your external drive BTRFS partition.
                  • Your @home backup subvolume is on sdb1 and is a read-only subvolume.


                  Here's the steps with terminal commands:
                  Make yourself root user:
                  sudo -i

                  Make mount locations for the sda2 and sdb1:
                  mkdir /mnt/subvol
                  mkidr /mnt/external


                  Mount the file systems:
                  mount /dev/sda2 /mnt/subvol
                  mount /dev/sdb1 /mnt/
                  external

                  Delete the 19.10 @home subvolume:
                  btrfs su de -c /mnt/subvol/@home

                  Send a copy of the backup @home to sda2:
                  btrfs send -v /mnt/external/@home | btrfs receive -v /mnt/subvol

                  Change the state if the received @home to read-write:
                  btrfs property set -ts /mnt/subvol/@home ro false

                  Reboot
                  reboot


                  That's all you have to do. Note the send|receive part will take some time depending on the speed of the connection and the size of the subvolume. Also, pay attention to the output of this command. The "-v" switches will give to a "received" transaction ID but more importantly, a send Exit Status that should look like this:

                  BTRFS_IOC_SEND returned 0

                  Zero means success. IF you get anything else, something went wrong.

                  If you decide to keep the 19.10 @home subvolume "just in case", then replace the btrfs su de -c command with mv and give it a new name.
                  Last edited by oshunluvr; Oct 20, 2019, 07:06 AM.

                  Please Read Me

                  Comment


                    #10
                    Note that this will wipe anything you have done in your home if you've booted to the new install. If that matters to you, you may want to do something different.

                    Please Read Me

                    Comment


                      #11
                      I'm a little sloppy with the terminology at times, but you have correctly guessed my intentions and the explanation is all very clear. My only doubt at the moment is that my backup @home on the external HD is labelled with date and time stamps, so if I just send it to the new install it will keep the same date/time stamps, right? How do I get it to read just @home?

                      Comment


                        #12
                        Date and time stamps update when the file is touched. A BTRFS send|receive will not change any time stamps.

                        Why do you think the time stamps matter? The system isn't going to reject anything based on a time stamp. AFAIK, it doesn't even look at them other than to update them when a file is accessed.

                        I'm not sure what you mean about "read just @home". If you send your backup @home to replace the 19.20 @home, the install isn't going to know the difference because it will be mounted just like the previous @home was.

                        Please Read Me

                        Comment


                          #13
                          Just a matter of aesthetics. My backup @home, made with the BTRFS Subvolume Manager, automatically has the date and time on the snapshot when it is sent it from the snapshot folder to the ext. HD. I would prefer the @home on the new install just to have the name @home. So I guess I just use the mv command, right? By the way, I'm in the transfer process right now, after a successful new installation of 19.10. It seems a lot easier than upgrading. I tried Vinny's method of upgrading 18.04 to 19.10 and got hung up at 87%. It also took a lot of time, about one hour every 10%.

                          Comment


                            #14
                            OK, yes you would need to rename the @home backup to "@home" then do the business I listed above. When you said "timestamps" I thought you meant the actual time/date stamp on the files not the file name of the subvolume,

                            I didn't think about the default name change if you use the service menu I wrote. If you don't like that and have upgraded the the latest version, it allows to to manually enter something else. You can also change the default within the service menu file itself.

                            Please Read Me

                            Comment


                              #15
                              Thanks. Everything came out all right--just have to renew some settings, etc. A very quick way to upgrade.

                              Comment

                              Working...
                              X