Hello guys.
i have several backup servers which i have to monitor them daily.
now i want an script to use the backup directory and put it in output variable.
my backup files look like this:
as you can see file names contain the date and the type of backup(just level and full are important to me)
now i want return the values like this:
if the backup date belong to today or yesterday and backup type was full return 10
if the backup date belong to today or yesterday and backup was level return 5
and if non of them was true return 0.
i have no idea how can:
1- put the files name in a string.
2- how can extract the last backup date and type?
3- how can compare the date with current day?
sorry for asking questions like this. i just start shell scripting but this one is kind of emergency.
thank you so much.
i have several backup servers which i have to monitor them daily.
now i want an script to use the backup directory and put it in output variable.
my backup files look like this:
Code:
[ll -hrt
total 151G
-rw-r----- 1 oracle oinstall 68G Jan 23 00:21 full_ORCL_20150122_7277_1.bck
-rw-r----- 1 oracle oinstall 1.3G Jan 23 00:24 arch_ORCL_20150123_7279_1.bck
-rw-r----- 1 oracle oinstall 444M Jan 24 21:12 level1_ORCL_20150124_7281_1.bck
-rw-r----- 1 oracle oinstall 1.3G Jan 24 21:16 arch_ORCL_20150124_7283_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 24 21:16 c-1229942357-20150124-01
-rw-r----- 1 oracle oinstall 664M Jan 25 21:16 level1_ORCL_20150125_7285_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 25 21:16 c-1229942357-20150125-00
-rw-r----- 1 oracle oinstall 1.2G Jan 25 21:35 arch_ORCL_20150125_7287_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 25 21:35 c-1229942357-20150125-01
-rw-r----- 1 oracle oinstall 870M Jan 26 21:32 level1_ORCL_20150126_7289_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 26 21:32 c-1229942357-20150126-00
-rw-r----- 1 oracle oinstall 1.2G Jan 26 21:42 arch_ORCL_20150126_7291_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 26 21:42 c-1229942357-20150126-01
-rw-r----- 1 oracle oinstall 1.2G Jan 27 21:16 level1_ORCL_20150127_7293_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 27 21:16 c-1229942357-20150127-00
-rw-r----- 1 oracle oinstall 1.2G Jan 27 21:33 arch_ORCL_20150127_7295_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 27 21:33 c-1229942357-20150127-01
-rw-r----- 1 oracle oinstall 1.4G Jan 28 21:31 level1_ORCL_20150128_7297_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 28 21:31 c-1229942357-20150128-00
-rw-r----- 1 oracle oinstall 1.2G Jan 28 21:51 arch_ORCL_20150128_7299_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 28 21:51 c-1229942357-20150128-01
-rw-r----- 1 oracle oinstall 68G Jan 30 07:01 full_ORCL_20150129_7301_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 30 07:02 c-1229942357-20150130-00
-rw-r----- 1 oracle oinstall 1.4G Jan 30 07:05 arch_ORCL_20150130_7303_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 30 07:05 c-1229942357-20150130-01
drwxr-xr-x 2 oracle oinstall 16K Jan 31 21:01 rman
-rw-r----- 1 oracle oinstall 436M Jan 31 21:13 level1_ORCL_20150131_7305_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 31 21:13 c-1229942357-20150131-00
-rw-r----- 1 oracle oinstall 1.4G Jan 31 21:16 arch_ORCL_20150131_7307_1.bck
-rw-r----- 1 oracle oinstall 11M Jan 31 21:17 c-1229942357-20150131-01
now i want return the values like this:
if the backup date belong to today or yesterday and backup type was full return 10
if the backup date belong to today or yesterday and backup was level return 5
and if non of them was true return 0.
i have no idea how can:
1- put the files name in a string.
2- how can extract the last backup date and type?
3- how can compare the date with current day?
sorry for asking questions like this. i just start shell scripting but this one is kind of emergency.
thank you so much.