Announcement

Collapse
No announcement yet.

exclude folder from snapshots and backups

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

    [SOLVED] exclude folder from snapshots and backups

    Is it possible to exclude folder from snapshots and backups? For example a content of /home/user/Download often changes and I prefer not to backup it because these files I manage manually, I mean delete or move to USB when I want to. In other words I don't want to have them restored while recovering /home.

    Can you write more how do you work with files, when you want to recover from btrfs backup a single file?

    #2
    A snapshot of / can be browsed with Dolphin just like its source, /, can be browsed. If you modify or delete a file or directory in / you can use the cp command or drag & drop in Dolphin, or mc, to copy that file or directory from within the snapshot back to /. So, a snapshot gives you the ability to restore any file or directory with ease, without doing a full rollback. Ditto for /home.

    While browsing a snapshot of / you will notice that it includes /home. However, if you browse into /home you will notice that it is empty. /home is a nested subvolume of /. The contents of nested subvolumes are not included in a snapshot of the parent subvolume. *ubuntu's uses only two subvolumes initially, @ (/) and @home (/home). That's why, when preserving a system, one must make snapshots of both at the same time, in a pair.

    If you do not want to have the subdirectory /home/youracct/Downloads included in a snapshot of @home, then make that subdirectory a subvolume, @Downloads, and mount it to /home/youracct/Downloads in fstab.

    First, at the <ROOT_FS> level, create the @Downloads subvolume.
    sudo -i
    sudo mount /dev/disk/by-uuid/uuidofsda1 /mnt

    /mnt is now the <ROOT_FS>.
    A vdir /mnt will show
    /mnt/@
    /mnt/@home
    and if you have created a snapshots directory
    /mnt/snapshots

    Create @Downloads under /mnt
    cd /mnt
    btrfs su create @Downloads
    sudo chown myuser:myuser @Downloads (this step left out due to absent mindedness).

    Use Dolphin or mc to move all of /home/youracct/Download's contents to @Download, leaving an empty directory.

    The uuid of @Download will be the same as the uuid of @ or @home because they are at the same level of <ROOT_FS>.

    Edit /etc/fstab and add
    UUID=sameuuidof@or@home /home/youracct/Downloads btrfs defaults,subvol=@Downloads 0 3
    Hint: just copy the /home line and add it below the /home line and modify it. The uuid will be the same.

    Save the file.
    Reboot and verify that all the files you moved to @Downloads are still in /home/youracct/Downloads.
    Don't change the parameters because only the parameters of the / line will be read and honored. Modifying the rest is a waste of time, and is usually made the same as the / line for reference sake.

    Now, when ever you make a snapshot of /home the /home/youracct/Downloads directory will NOT be included. You can, however, make a snapshot of @Downloads to preserve it, if you ever want to.

    Another way is to avoid saving files and subdirectories in a @home snapshot is to simply do the mount steps listed above, browse into /mnt/snapshots/@homeYYYYMMDD, and delete every file and directory inside @homeYYYYMMDD/home/youracct/Downloads. The mc tool does it very swiftly and easily. IF you want to restore /home/youracct/Downloads to its former behavior then simply put a # in front of the line you added to /etc/fstab and reboot. Then you can delete @Downloads.
    Last edited by GreyGeek; Aug 17, 2018, 04:25 PM.
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment


      #3
      Thank you for putting that in plain language.

      I'd like to know the best, or perhaps recommended by the members here, practice for storing personal databases in a Kubuntu install with BTRFS. I had some data in mysql when my 17.10 install got corrupted, and it was a mission to get it out. I was dumpling roughly monthly and the failure came towards the end of that cycle. I belatedly learned that the data (a tiny amount really, a few MB) was in /var by default. I'm also having a play with postgresql.

      Regards, John Little
      Regards, John Little

      Comment


        #4
        AFAIK, it is not possible to It is possible to format a partition with EXT4 and, running PostgreSQL on a Btrfs filesystem, mount the partition and create a PostgreSQL database on the mounted EXT4 partition because one cannot can mount an EXT4 partition to a Btrfs filesystem [but] CoW does NOT work on EXT4 [so snapshots will not contain the EXT4 partition]. One will have to use the PostgreSQL backup, restore and dump commands to preserve databases.

        My personal opinion is that using dynamic virtual HDs (VirtualBox or KVM/QEMU) or databases (MySQL, SLQLite, PostgreSQL) on Btrfs is a bad idea. Even if you use nodatacow on their image subdirectories BEFORE you created the HDs or databases. Nodatacow shuts down checksumming. On PostgreSQL 9.4 or higher checksumming is built in but when you create a snapshot Btrfs uses CoW to create it even if a subdir has nodatacow.

        So, IF I were to resume client-server programming I'd install Kubuntu or Neon on a second laptop server in my office using EXT4 and install PostgreSQL on it and connect to it via the LAN. I'd maintain it by running psql in a remote terminal. With that as an external destination I'd also use the "-f" switch on the Btrfs send & receive command to create ASCII streams of my snapshots to store on that server.

        Last weekend I tested KVM/QEMU virtual system. Once I created the virtual HD (even with a nodatacow /var/lib/libvirt/images) the performance and the screen response were in the toilet. After four hours of playing, trying to make it work better, I gave up and rolled back.
        Last edited by GreyGeek; Aug 17, 2018, 04:31 PM.
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          This is an excellent tutorial. You and oshunluvr are my btrfs teachers. Thank you.

          Thanks to you I already have learned how to make snapshots, backups and recover. I have to say that btrfs is like a dreams come true in my usage of Linux.

          Comment


            #6
            Originally posted by gnomek View Post
            This is an excellent tutorial. You and oshunluvr are my btrfs teachers. Thank you.

            Thanks to you I already have learned how to make snapshots, backups and recover. I have to say that btrfs is like a dreams come true in my usage of Linux.
            It removes the fear of experimentation and trying new things, doesn’t it!
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Originally posted by GreyGeek View Post
              Edit /etc/fstab and add
              UUID=sameuuidof@or@home /home/youracct/Downloads btrfs defaults,subvol=@Downloads 0 3
              I did it. I had a test file in Downloads. When I rebooted it disappeared. And I can't create a file in /home/gnomek/Downloads because it is mounted with root permissions.

              Code:
              btrfs subvolume list /
              ID 268 gen 540 top level 5 path @
              ID 269 gen 540 top level 5 path @home
              ID 273 gen 501 top level 5 path @Downloads

              Comment


                #8
                Originally posted by gnomek View Post
                I did it. I had a test file in Downloads. When I rebooted it disappeared.
                Was your test file in the /Downloads directory of @home (and not in @Downloads)? in that case it won't be visible if @Downloads is mounted at @home/Downloads. It becomes visible again if you unmount @Downloads.

                Originally posted by gnomek View Post
                And I can't create a file in /home/gnomek/Downloads because it is mounted with root permissions.
                You can use chown to change the ownership of a posix filesystem to your user, for example "sudo chown -r $USER:$USER /home/$USER/Downloads" (@Downloads needs to be mounted there for this to have an effect)

                Comment


                  #9
                  The key to do it properly was to change permissions of subvolume not folder.

                  Code:
                  sudo chown myuser:myuser @Downloads
                  and then move content from folder Downloads to @Downloads. After reboot everything works fine.

                  The solution was here:
                  https://www.kubuntuforums.net/showth...ome-data-files

                  It is still sticky in Miscellaneous. Administrator, please move it to BTRFS subforum.

                  Comment


                    #10
                    Originally posted by gnomek View Post
                    The key to do it properly was to change permissions of subvolume not folder.
                    If it's mounted there, using the folder should also work just fine, but you can of course use the subvolume as well (if you're using btrfs)...using the folder should work with any posix filesystem.

                    Comment


                      #11
                      Sorry, for coming late to this party...

                      I do something like this on my server. I have each "set" of stuff, Videos, Pictures, Downloads, etc. (14 in total) all in their own subvolumes then I mount them to the exported (NFS4 server) folders. This allows me run backups at different intervals or to skip some altogether. To a lesser extent, I do this on my home as well, as you saw on my post you referred to.

                      Post moved...

                      Please Read Me

                      Comment


                        #12
                        Originally posted by gnomek View Post
                        The key to do it properly was to change permissions of subvolume not folder.

                        Code:
                        sudo chown myuser:myuser @Downloads
                        and then move content from folder Downloads to @Downloads. After reboot everything works fine.

                        The solution was here:
                        https://www.kubuntuforums.net/showth...ome-data-files

                        It is still sticky in Miscellaneous. Administrator, please move it to BTRFS subforum.
                        Yup, oshunluver included this line:

                        sudo chown myuser:myuser @mydocuments

                        but in my brief explanation I left out that step. My bad. I've included it in the post above for completeness.
                        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                        – John F. Kennedy, February 26, 1962.

                        Comment

                        Working...
                        X