Restore single files from a btrfs snapshot without doing a full copy

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Background



I maintain a series of hourly snapshots on my btrfs filesystem using btrbk. The subvolume and snapshots are stored like this (names shortened to make it easier to follow):



/@vol (subvolume)
/btrbk/@vol.00 (snapshots of /@vol, one per hour)
/btrbk/@vol.01 ...
/home/user/vol (mountpoint for /@vol)


Now I deleted a single file in /home/user/vol which I should not have deleted. No problem, I can easily restore from the latest snapshot:



# cd /home/user/vol
# cp -a --reflink=always /btrbk/@vol.01/all_ipv4_numbers.txt ./
cp: failed to clone './all_ipv4_numbers.txt' from '/btrbk/@vol.01/all_ipv4_numbers.txt': Invalid cross-device link


Seems I can't "reflink" the file. But I don't want to end up with two copies of the file. Ideally I want it to look like nothing happened between the most recent snapshot and the next snapshot that will be taken in the future.



(Yes, I also have actual backups, but restoring from snapshots are more convenient whenever available!)



Question



How do I restore a single file from a btrfs snapshot while keeping all the nice references and magic that makes btrfs know that it is the same data in all the snapshots?









share

























    up vote
    0
    down vote

    favorite












    Background



    I maintain a series of hourly snapshots on my btrfs filesystem using btrbk. The subvolume and snapshots are stored like this (names shortened to make it easier to follow):



    /@vol (subvolume)
    /btrbk/@vol.00 (snapshots of /@vol, one per hour)
    /btrbk/@vol.01 ...
    /home/user/vol (mountpoint for /@vol)


    Now I deleted a single file in /home/user/vol which I should not have deleted. No problem, I can easily restore from the latest snapshot:



    # cd /home/user/vol
    # cp -a --reflink=always /btrbk/@vol.01/all_ipv4_numbers.txt ./
    cp: failed to clone './all_ipv4_numbers.txt' from '/btrbk/@vol.01/all_ipv4_numbers.txt': Invalid cross-device link


    Seems I can't "reflink" the file. But I don't want to end up with two copies of the file. Ideally I want it to look like nothing happened between the most recent snapshot and the next snapshot that will be taken in the future.



    (Yes, I also have actual backups, but restoring from snapshots are more convenient whenever available!)



    Question



    How do I restore a single file from a btrfs snapshot while keeping all the nice references and magic that makes btrfs know that it is the same data in all the snapshots?









    share























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Background



      I maintain a series of hourly snapshots on my btrfs filesystem using btrbk. The subvolume and snapshots are stored like this (names shortened to make it easier to follow):



      /@vol (subvolume)
      /btrbk/@vol.00 (snapshots of /@vol, one per hour)
      /btrbk/@vol.01 ...
      /home/user/vol (mountpoint for /@vol)


      Now I deleted a single file in /home/user/vol which I should not have deleted. No problem, I can easily restore from the latest snapshot:



      # cd /home/user/vol
      # cp -a --reflink=always /btrbk/@vol.01/all_ipv4_numbers.txt ./
      cp: failed to clone './all_ipv4_numbers.txt' from '/btrbk/@vol.01/all_ipv4_numbers.txt': Invalid cross-device link


      Seems I can't "reflink" the file. But I don't want to end up with two copies of the file. Ideally I want it to look like nothing happened between the most recent snapshot and the next snapshot that will be taken in the future.



      (Yes, I also have actual backups, but restoring from snapshots are more convenient whenever available!)



      Question



      How do I restore a single file from a btrfs snapshot while keeping all the nice references and magic that makes btrfs know that it is the same data in all the snapshots?









      share













      Background



      I maintain a series of hourly snapshots on my btrfs filesystem using btrbk. The subvolume and snapshots are stored like this (names shortened to make it easier to follow):



      /@vol (subvolume)
      /btrbk/@vol.00 (snapshots of /@vol, one per hour)
      /btrbk/@vol.01 ...
      /home/user/vol (mountpoint for /@vol)


      Now I deleted a single file in /home/user/vol which I should not have deleted. No problem, I can easily restore from the latest snapshot:



      # cd /home/user/vol
      # cp -a --reflink=always /btrbk/@vol.01/all_ipv4_numbers.txt ./
      cp: failed to clone './all_ipv4_numbers.txt' from '/btrbk/@vol.01/all_ipv4_numbers.txt': Invalid cross-device link


      Seems I can't "reflink" the file. But I don't want to end up with two copies of the file. Ideally I want it to look like nothing happened between the most recent snapshot and the next snapshot that will be taken in the future.



      (Yes, I also have actual backups, but restoring from snapshots are more convenient whenever available!)



      Question



      How do I restore a single file from a btrfs snapshot while keeping all the nice references and magic that makes btrfs know that it is the same data in all the snapshots?







      btrfs snapshot





      share












      share










      share



      share










      asked 5 mins ago









      pipe

      303114




      303114

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476925%2frestore-single-files-from-a-btrfs-snapshot-without-doing-a-full-copy%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476925%2frestore-single-files-from-a-btrfs-snapshot-without-doing-a-full-copy%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay