How to create a snapshot in the command line

Discussion on setting up QNAP NAS products.
Locked
torsknod
New here
Posts: 4
Joined: Mon Feb 13, 2017 7:38 pm

How to create a snapshot in the command line

Post by torsknod »

Hello,
I have created a cron job (shell script) to ssh+rsync files from a remote server to a NAS directory on a separate volume.
Now I would like to snapshot this after every rsync. Creating a snapshot with

Code: Select all

lvcreate
does not make it visible in the GUI.
I found out that

Code: Select all

/home/httpd/cgi-bin/disk/snapshot.cgi
is used by the Web GUI to create the snapshots, which links library

Code: Select all

/usr/lib/libuLinux_Storage.so.0.0
. This library contains several functions which could be used to create snapshots, but even in the QDK there is no include file for it.
Would be nice if someone could help me.

Thanks in Advance
Torsten Knodt
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: How to create a snapshot in the command line

Post by OneCD »

Hi Torsten and welcome to the forum. :)
torsknod wrote:I have created a cron job (shell script) to ssh+rsync files from a remote server to a NAS directory on a separate volume.
Now I would like to snapshot this after every rsync. Creating a snapshot with

Code: Select all

lvcreate
does not make it visible in the GUI.
Like many functions in QTS, there is a low-level component (lvcreate) and a high-level component (QTS GUI). You'd need to work out where QTS stores its snapshot configuration info. If you can find this file and modify it directly with info compatible with your low-level operation, then the QTS GUI might show this. :geek:

I don't use snapshots, so can't advise you as to where this info is stored. But maybe you could start in /etc/config. I'd suggest that you perform the high-level function (through the QTS GUI), then SSH in and see what files have been recently modified.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
torsknod
New here
Posts: 4
Joined: Mon Feb 13, 2017 7:38 pm

Re: How to create a snapshot in the command line

Post by torsknod »

OneCD wrote:
torsknod wrote:Creating a snapshot with

Code: Select all

lvcreate
does not make it visible in the GUI.
Like many functions in QTS, there is a low-level component (lvcreate) and a high-level component (GUI). You'd need to work out where QTS stores its snapshot configuration info. If you can find this file and modify it directly with info compatible with your low-level operation, then the QTS GUI might show this. :geek:

I don't use snapshots, so can't advise you as to where this info is stored. But maybe you could start in /etc/config. I'd suggest that you perform the high-level function (through the QTS GUI), then SSH in and see what files have been recently modified.
I already tried to add the same tags to the snapshot volume as they are created by the GUI and modified the configuration file in /etc/config/qsnapshot but this doesn't result in the snapshot being visible in the GUI. Also the entries in the file are relatively complex. That is why I tried to find out what snapshot.cgi is doing and came to this library. In the meantime I looked into the symbol table and found some functions which might be right. Unfortunately I did not find an include file for them so it is hard to get the arguments right.
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: How to create a snapshot in the command line

Post by OneCD »

torsknod wrote:In the meantime I looked into the symbol table and found some functions which might be right. Unfortunately I did not find an include file for them so it is hard to get the arguments right.
Ah, it looks like you are more able than I. :geek:

Hope you can work this out.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
torsknod
New here
Posts: 4
Joined: Mon Feb 13, 2017 7:38 pm

Re: How to create a snapshot in the command line

Post by torsknod »

I found a way with a hack in C using a function in the same library (libuLinux_Storage.so), snapshot.cgi is using. I will post details tomorrow.
kugelkopf
New here
Posts: 4
Joined: Mon Nov 07, 2016 2:46 am

Re: How to create a snapshot in the command line

Post by kugelkopf »

And? How did you do that?

Im searching for an option to make daily and weekly snapshots. The daily should stay for 14 days and the weekly for 6 month.
I've add some lines in /etc/config/qsnapshot/snapshotSchedule.conf. This works for making the daily and the weekly snapshots but the NAS use the 6 month expire time for both snapshots although I have adapted the expiremin value for the daily Snapshot...

Someone an idea?
kirtlander
First post
Posts: 1
Joined: Tue Mar 27, 2018 3:57 am

Re: How to create a snapshot in the command line

Post by kirtlander »

+1 - I love the snapshot functionality; but I would also like the ability to either script it from the command line to allow more than one schedule or retention period for a given volume. I am still forced to either manually change the retention to permanent for those snapshots that we need to keep around forever, or use some other mechanism to persist the state of storage for longer term recovery availability. I'd love to be able to enable the the following scenario:

7 daily snapshots, expire in 7 days
8 weekly snapshots, expire in 8 weeks
12 monthly snapshots, expire in 1 year
yearly snapshots, keep permanently
PFITS
New here
Posts: 3
Joined: Tue Apr 02, 2019 5:32 pm

Re: How to create a snapshot in the command line

Post by PFITS »

Is it possible now to trigger a Snapshot from SSH or command line (which is basically the same).
I would need to start the Snapshot from an external event, which would run a ssh command.

Is taking a (preconfigured) snapshot with command line possible in any way?

Thanks in advance!
User avatar
storageman
Ask me anything
Posts: 5506
Joined: Thu Sep 22, 2011 10:57 pm

Re: How to create a snapshot in the command line

Post by storageman »

I can see any scripting might get the snapshot GUI and available space reports and its records into a right mess.
PFITS
New here
Posts: 3
Joined: Tue Apr 02, 2019 5:32 pm

Re: How to create a snapshot in the command line

Post by PFITS »

OK, but what if there is some possibility to run the same command like starting the snapshot from GUI? That would be perfect!
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: How to create a snapshot in the command line

Post by OneCD »

PFITS wrote: Tue Apr 02, 2019 7:13 pm OK, but what if there is some possibility to run the same command like starting the snapshot from GUI?
Maybe you could monitor the process list (with htop, top, ps, etc...), then create a snapshot via the UI? ;)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
PFITS
New here
Posts: 3
Joined: Tue Apr 02, 2019 5:32 pm

Re: How to create a snapshot in the command line

Post by PFITS »

That could work, but I think there is more in the Background, maybe some Database that tracks all actions on the GUI and then something could go wrong.
I find it very interesting, that there is no standard for doing this...
tramCS
New here
Posts: 4
Joined: Sun Jun 24, 2018 2:42 am

Re: How to create a snapshot in the command line

Post by tramCS »

Hello.

Can somebody explain me, how can i make a snapshot at the commandline.

When i make a "lvcreate -s -n test lv", the new volume test is inactive and i cant make this active.

Thanks a lot
Christian
Locked

Return to “Turbo Station Installation & Setup”