Giter Site home page Giter Site logo

btrfs-snap's People

Contributors

baracoder avatar bkloppenborg avatar chipturner avatar dunedan avatar gitmopp avatar gpacgpac avatar jf647 avatar lpirl avatar nazar-pc avatar phasip avatar serpedon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

btrfs-snap's Issues

Problem with time and stat

I'm on a Ubuntu 16.04

And here is my problem:

root:/mnt/root# btrfs sub create test 
Create subvolume './test'
root:/mnt/root# cd test/

root:/mnt/root/test# stat /mnt/root/test
  File: '/mnt/root/test'
  Size: 0         	Blocks: 0          IO Block: 4096   directory
Device: 3eh/62d	Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-08 15:55:13.916941738 +0100
Modify: 2018-02-08 15:55:11.144919869 +0100
Change: 2018-02-08 15:55:11.144919869 +0100
 Birth: -

root:/mnt/root/test# touch test_file
root:/mnt/root/test# stat /mnt/root/test
  File: '/mnt/root/test'
  Size: 18        	Blocks: 0          IO Block: 4096   directory
Device: 3eh/62d	Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-08 15:55:13.916941738 +0100
Modify: 2018-02-08 15:55:35.401111346 +0100
Change: 2018-02-08 15:55:35.401111346 +0100
 Birth: -

root:/mnt/root/test# mkdir subdir
root:/mnt/root/test# stat /mnt/root/test
  File: '/mnt/root/test'
  Size: 30        	Blocks: 0          IO Block: 4096   directory
Device: 3eh/62d	Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-08 15:55:13.916941738 +0100
Modify: 2018-02-08 15:55:46.333197729 +0100
Change: 2018-02-08 15:55:46.333197729 +0100
 Birth: -

root:/mnt/root/test# touch subdir/subfile
root:/mnt/root/test# stat /mnt/root/test
  File: '/mnt/root/test'
  Size: 30        	Blocks: 0          IO Block: 4096   directory
Device: 3eh/62d	Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-08 15:55:54.017258478 +0100
Modify: 2018-02-08 15:55:46.333197729 +0100
Change: 2018-02-08 15:55:46.333197729 +0100
 Birth: -

root:/mnt/root/test# btrfs --version
btrfs-progs v4.4

As you can see, I create a sub volume, some directories and some files.

The problem is, if I modifiy a file in a subdirecto, it doest not update the modification date of the subvolume.

The problem is that btrfs-snap -t and btrfs-snap -T use the stat command to know if the snapshot should be done or not.

Qgroups not deleted when snapshot is removed ?

Hi, and thanks for your script !
Do you think you could manage the qgroup deletion when delting an old snap, since it's a known limitation in btrfs ?
After 2 weeks, and many hourly snaps, I've >25000 lines in the command
btrfs qgroup show /home

Thanks in advance !

No go with VFS

Just downloaded your script to help me automate btrfs snapshot. Unfortunately, it doesn't work when the VFS option is used:

./btrfs_snap -r -c -d .snapshots -t 300 /btrfs/backup/nearline VFS 4

Create a readonly snapshot of '/btrfs/backup/nearline' in '/btrfs/backup/nearline/.snapshots/@GMT-2016.02.19-19.01.35'
ls: cannot access /btrfs/backup/nearline/.snapshots//btrfs/backup/nearline: No such file or directory
ls: cannot access VFS: No such file or directory
ls: cannot access 4GMT-????.??.??-??.??.??: No such file or directory

However this works:

./btrfs_snap -r -c -d .snapshots -t 300 /btrfs/backup/nearline hourly 4
Create a readonly snapshot of '/btrfs/backup/nearline' in '/btrfs/backup/nearline/.snapshots/hourly_2016-02-19_14-06-15'

Note, the error only occurs when the VFS prefix is used.

What am I doing wrong?
OS: CentOS 7 64-bit

Can't get btrfs-snap to work on Arch Linux

Using btrfs-snap 1.7.3 from AUR.

[0] % pacman -Q btrfs-progs btrfs-snap
btrfs-progs 4.13-1
btrfs-snap 1.7.3-1

Maybe I'm misunderstanding how this tool works?

c0rn3j@Lappy : ~
[1] % sudo btrfs-snap /var/lib/machines hourly 24 
ERROR: /var/lib/machines is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)

c0rn3j@Lappy : ~
[1] % sudo btrfs-snap / hourly 24     
btrfs subvolume show: too few arguments
usage: btrfs subvolume show [options] <subvol-path>|<mnt>

    Show more information about the subvolume

    -r|--rootid   rootid of the subvolume
    -u|--uuid     uuid of the subvolume

    If no option is specified, <subvol-path> will be shown, otherwise
    the rootid or uuid are resolved relative to the <mnt> path.

ERROR:  is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)
c0rn3j@Lappy : ~
[1] % sudo btrfs subvolume show /
/
	Name: 			<FS_TREE>
	UUID: 			-
	Parent UUID: 		-
	Received UUID: 		-
	Creation time: 		-
	Subvolume ID: 		5
	Generation: 		42061
	Gen at creation: 	0
	Parent ID: 		0
	Top level ID: 		0
	Flags: 			-
	Snapshot(s):
				var/lib/machines
				test

Snapshot on mountpoint "/" is not working

I was trying to snapshot on moutpoint / by using command /root/btrfs-snap/btrfs-snap / 10min 12
And I get following error message (with set -x)

+ mp=
+ prefix=daily
+ cnt=1
+ mount -t btrfs
+ cut -d ' ' -f 3
+ grep '^$'
+ '[' 1 -ne 0 ']'
+ btrfs subvolume show
+ grep '$'
btrfs subvolume show: too few arguments
usage: btrfs subvolume show [options] <subvol-path>|<mnt>

    Show more information about the subvolume

    -r|--rootid   rootid of the subvolume
    -u|--uuid     uuid of the subvolume

    If no option is specified, <subvol-path> will be shown, otherwise
    the rootid or uuid are resolved relative to the <mnt> path.

+ '[' 1 -ne 0 ']'
+ log.error ' is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)'
+ logger -p local0.err -t btrfs-snap ' is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)'
+ echo 'ERROR:  is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)'
ERROR:  is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)
+ exit 1

I found that PR #17 solve this issue
It will be great if the patch is merged.

Thanks :)

Weekly and Daily

Hello,

I would like to have weekly, daily and monthly snapshots.
Is that possible in one command (I think not) or at least in one crontab-entry?

I am going to create one script that does iterate through all folders I intend to backup and I wonder, if I need to create three scripts, or whether I can go with one.

Greetings,
Hendrik

ERROR: .... is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19) Ubuntu 20.04

btrfs-snap version: 1.7.3
btrfs-progs version : 5.4.1
root btrfs volume : /var/fileserver
btrfs subvolume : /var/fileserver/data/active

When Verifying that the path is either a valid btrfs mountpoint or a subvolume

# Verify that the path is either a valid btrfs mountpoint
mount -t btrfs | cut -d " " -f 3 | grep "^${mp}$" > /dev/null
if [ $? -ne 0 ] ; then
    # or a valid snapshot matching mp
    btrfs subvolume show $mp | grep "${mp}$" > /dev/null
    if [ $? -ne 0 ] ; then
        log.error "${mp} is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)"
        exit 1;
    fi
fi

with btrfs-progs version 4.4:
btrfs subvolume show /var/fileserver/data/active
the output would look like this:

/var/fileserver/data/active
        Name:                   active
        UUID:                   84638c7b-742f-3c4a-a6ba-6d64b82cba71
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2018-02-10 15:02:47 +0100
        Subvolume ID:           260
        Generation:             233633
        Gen at creation:        25
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Snapshot(s):

with btrfs-progs version 5.4.1:
the same command btrfs subvolume show /var/fileserver/data/active output:

data/active
        Name:                   active
        UUID:                   57e8d80f-99b6-394d-9b12-bc766e0a249a
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2022-02-17 13:54:53 +0000
        Subvolume ID:           258
        Generation:             308
        Gen at creation:        8
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Snapshot(s):

the "full" path is not present anymore /var/fileserver/data/active != data/active

the command btrfs subvolume show $mp | grep "${mp}$" will always retrun exit code 1 leading the script to stop.

A solution is to adapt the script like this, in order to grep the correct subvolume name :

# Verify that the path is either a valid btrfs mountpoint
mount -t btrfs | cut -d " " -f 3 | grep "^${mp}$" > /dev/null
if [ $? -ne 0 ] ; then
    # or a valid snapshot matching mp
    # Get the path of the root volume as a prefix
    rv=$(mount -t btrfs | cut -d " " -f 3)
    # Remove the prefix with the / from the full path
    vn=${mp#"$rv/"}
    btrfs subvolume show $mp | grep "$vn" > /dev/null
    if [ $? -ne 0 ] ; then
        log.error "${mp} is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)"
        exit 1;
    fi
fi

Hope it helps someone....

syntax error

Hi

I have an errpr message:

# btrfs-du 
Subvolume                                                         Total  Exclusive  ID        
─────────────────────────────────────────────────────────────────────────────────────────
@rootfs                                                                             257       
/usr/local/sbin/btrfs-du: line 118: EXCL_TOTAL +  : syntax error: operand expected (error token is "+  ")
─────────────────────────────────────────────────────────────────────────────────────────
Total exclusive data                                                             0Bytes

This is on ubuntu xenial, btrfs rootfs, on odroid arm platform.
Thanks

Please tag releases

Hi,
I want to create a package for Arch Linux. Do you mind creating git tags for the release commits (aka version bumps)? That would simplify packaging. :)

/btrfs/system/@root is not a btrfs mountpoint

I use a folder /btrfs/system to mount my btrfs root. Inside /btrfs/system I place snapshots inside /btrfs/system/snapshots.

tree -d -L 1 /btrfs/system/
/btrfs/system/
├── @home
├── @root
├── snapshots

I'am using this structure for a few years now and never had problems with btrfs-snap until today.

Calling:

btrfs-snap -r -c -B /btrfs/system/snapshots /btrfs/system/@root root_daily 7

throws ERROR: /btrfs/system/@root is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19).

Changing btrfs subvolume show $mp | grep "${mp}$" > /dev/null to btrfs subvolume show $mp | grep $(basename $mp) > /dev/null fixes the issue.

vfs_snapshot breaks snapshots of /

root@rcpt:/srv/stash# bash -x /opt/btrfs-snap/bin/btrfs-snap -b /snapshots -r / 3h 8
+ base=
+ readonly=
+ getopts hVrb: arg
+ case "${arg}" in
+ base=/snapshots
+ getopts hVrb: arg
+ case "${arg}" in
+ readonly=-r
+ getopts hVrb: arg
+ shift 3
+ '[' 3 -ne 3 ']'
++ sed -e 's#/$##'
++ echo /
+ mp=
+ pf=3h
+ cnt=9
+ grep '^$'
+ cut -d ' ' -f 3
+ mount -t btrfs
+ '[' 1 -ne 0 ']'
+ echo 'Error:  is not a btrfs mountpoint'
Error:  is not a btrfs mountpoint
+ exit 1
root@rcpt:/srv/stash#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.