Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to print a server's configuration

Status
Not open for further replies.

peppe71

Technical User
Feb 6, 2002
27
IT
I need help to write a script to print a configuration of a backup server in tabular mode.
I need the following items:
group, client, name, retention
 

Hi,


You could use nsradmin to do that.

E.g.: echo print NSR client | nsradmin -s servername

will print out your client infos, and you can than filter for the valuable lines (like group, name, retention policy).

BR,
Patrik
 
With nsradmin i can print a configuration not in tabular mode, such as:

name: bc2;
retention policy: Week;
group: BC_7g;
save set: All;

name: bc3;
retention policy: Year;
group: BC_1y;
save set: /home;

I want a output such as:

name retention group save set
bc2 week BC_7g All
bc2 Year BC_1y /home
 
I need help in a Unix backup server.
Have you a script to do this?
 

Hi,

Something link this would do it. Just change the server name after the nsradmin command!

echo print NSR client | nsradmin -s servername | grep "name:\|retention policy:\|group:\|save set:" | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t | sed 's/ *name: //' | sed 's/ *name: /\n/g' | sed 's/;//g'

BR,
Patrik
 

It worked for me on a Linux server, with bash shell. So if you are not using bash as the default shell, please run a bash command and try to run it again.

If it doesn't help, try to debug the complex command, by running it partially. E.g.:

start with: echo print NSR client | nsradmin -s servername
and check if you see anything. If the output is OK, add the next command to the end, like: echo print NSR client | nsradmin -s servername | grep "name:\|retention policy:\|group:\|save set:"

And so on. let me know where you loose the output...

Patrik

 
nsradmin -i query | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t

more query
show name;group;retention policy;save set
p type: NSR client;
With this script i see list of client, save sets, retention and groups

nsradmin -i query | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t | sed 's/ *name: //'

With this script i don't see nothing

 

This is because your query gives a different output compared to if you run the nsradmin command without the -i query option. So filtering has to be changed :)

So try this:

nsradmin -i query | sed '/^$/ d' | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t | sed 's/ *name: //' | sed 's/ *name: /\n/g' | sed 's/;//g' | sed 's/\t\\//g' | sed 's/\t\t/\t/g'


BR,
Patrik
 
I don't see anything.
Only running the following command i can see something:

nsradmin -i query | sed '/^$/ d' | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t

If i add "sed 's/ *name: //'" into the script i can't obtain any output
 

Could you copy here the output of
nsradmin -i query | sed '/^$/ d'
(just the first 20 lines!)

BR,
Patrik
 
nsradmin -i query | sed '/^$/ d' |more
name: bck-srv;
retention policy: Day;
group: BILL-WEEK_REPORT_30g;
save set: /etc/hosts;
name: db-sqlce;
retention policy: 15 Days;
group: DMSS-ORARI_7g;
save set: \
"H:\\Program Files\\Microsoft SQL Server\\MSSQL\\BACKUP\\DE_WDMS_DOCUMENTALE\\\
*.trn";
name: fe2;
retention policy: 5 Years;
group: NAUT_5y;
save set: All;
name: ifcl1-1;
retention policy: 15 Days;
group: IFOLD_15g;
save set: all;
name: dbm-sqlclue;
retention policy: 15 Days;
group: DMSF-SQL_15g;
save set: "MSSQL:";
name: dbe1;
retention policy: 15 Days;
group: DMSG_15g;
save set: "C:", "SYSTEM DB:", "SYSTEM FILES:",
"SYSTEM STATE:";
name: dbme2;
retention policy: 15 Days;
group: DMSF_15g2;
save set: "c:", "SYSTEM STATE:", "SYSTEM DB:",
"SYSTEM FILES:";
name: icm-sql02;
retention policy: 15 Days;
group: ICM-SO_15g;
save set: "C:", "SYSTEM DB:", "SYSTEM FILES:",
"SYSTEM STATE:";
name: icm-sql03;
retention policy: Month;
group: ICM_30g;
save set: "D:";
name: db-sqlclue;
retention policy: Week;
group: DMSF-ORARI_7g;
save set: \
"s:\\Program Files\\Microsoft SQL Server\\MSSQL\\BACKUP\\FR_WDMS_DOCUMENTALE\\\
*.trn";
 

Interesting....

Anyways, please take the sed command out which is after tr (sed 's/ *name: //'), don\t change anythign which is behind that sed, and rerun the script.

If nothing shows up again, please show me the output of:
nsradmin -i query | sed '/^$/ d' | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t


Patrik
 
bck-srv/gestione>nsradmin -i query | sed '/^$/ d' | sed 's/ *retention policy: //g' | sed 's/ *group: //g' | sed 's/ *save set: //g' | tr \\n \\t |more
name: bck-srv; Day; EBILL-WEEK_REPORT_30g; /etc/hosts; name: fe2
01; 5 Years; NAUT_5y; All; name: dbm-sqlclue; 15 Days; DMSF-SQL_15g; "MSSQL:"; name: dbme2; 15 Days; DMSF_15g2; "c:"
, "SYSTEM STATE:", "SYSTEM DB:", "SYSTEM FILES:"; name: c015620-db-sql
ce; 15 Days; DMSG-ORARI_7g; \ "H:\\Program Files\\Microsoft SQL Server\\MSSQL\\BACKUP\\DE_WDMS_DOCUMENTALE\\\ *.trn";
 

Hi,

Until the tr command the output looks perfect. I have no clue why the next sed is not working right for you.

I ran the script on a RedHat Enterprise Linux 4 and it is working fine. sed should give the same results for all Unix/Linux (at least for these simple transformations), but maybe the compatibility is not 100%. So I suggest to run the commands on a Linux client if you can. I have no other ideas.

BR,
Patrik

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top