{"id":441,"date":"2010-05-18T00:00:00","date_gmt":"2010-05-18T00:00:00","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2010\/05\/18\/new-checkpoint-tool-dbdel\/"},"modified":"2021-07-31T17:58:57","modified_gmt":"2021-07-31T17:58:57","slug":"new-checkpoint-tool-dbdel","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Firewalls\/Checkpoint\/new-checkpoint-tool-dbdel.html","title":{"rendered":"Check Point Tool – dbdel ver3.1"},"content":{"rendered":"
Fir3net.com is pleased to release dbdel ver3.1. This is basically a wrapper for Check Points existing dbver tool, but allows you to remove 100`s of Database Revisions with one simple command string. Unlike dbver where you have to add each database revision id. This allows you to add the amount your want to remove and then does the rest for you.<\/p>\n
Script<\/strong><\/p>\n You can copy and paste the script into your manager.<\/p>\n Adding the script to your manager<\/strong><\/p>\n Below shows you the steps required to add the tool to your Check Point manager.<\/p>\n Options<\/strong><\/p>\n Below shows you the switches the tool allows you to use.<\/p>\n -d\u00a0\u00a0\u00a0\u00a0\u00a0 number of db revisions to remove Count<\/strong><\/p>\n Remove DB Revisions<\/strong><\/p>\n Remove DB Revisions before <\/strong><\/p>\n Show the Size<\/strong><\/p>\n List Revisions<\/strong><\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" Fir3net.com is pleased to release dbdel ver3.1. This is basically a wrapper for Check Points existing dbver tool, but allows you to remove 100`s of Database Revisions with one simple command string. Unlike dbver where you have to add each database revision id. This allows you to add the amount your want to remove and … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"yoast_head":"\n#!\/bin\/bash\r\n#\r\n# DB Revision Deletion Tool v3.1\r\n# Author : Fir3net.com\r\n# Date \t : 13\/5\/10\r\n#\r\n\r\n. \/opt\/CPshrd-R??\/tmp\/.CPprofile.sh\r\n\r\n### CHECK OS IS LINUX ###\r\n\r\nOS=`uname`\r\nif [ \"${OS}\" != \"Linux\" ] ; then\r\necho \"${OS}\" is not currently supported by dbdel\\.\r\nexit 1\r\nfi\r\n\r\n### VARIABLES ###\r\n\r\nVERDB=$FWDIR\/conf\/db_versions\/database\/versioning_db.fws\r\nTOTALDBLIST=`grep _id $VERDB | sed 's\/.*(\\|)\/\/g'`\r\nTOTALDB=`grep _id $VERDB | sed 's\/.*(\\|)\/\/g' | wc -l | sed 's\/^ *\/\/g'`\r\nTOTALSIZE=`du -sh \/opt\/CPsuite-R65\/fw1\/conf\/db_versions\/repository\/ | awk ' { print $1 } '`\r\n\r\n### FUNCTIONS ###\r\n\r\nlist()\r\n{\r\nawk '\r\nBEGIN { print \" ----------------------------------\\n | ID Date |\\n ----------------------------------\" }\r\n\/ver_id|date\/{arr[i++]=gensub(\/^[^(]*\\(|\\)|\"\/,\"\",\"g\")}\r\narr[1]{print \" | \" arr[1]\" | \" arr[0]\" | \" ;i=0;delete arr}\r\nEND { print \" ----------------------------------\"}\r\n' \"${VERDB}\"\r\n}\r\n\r\ndelete()\r\n{ \r\n if [ \"${DELNUM}\" -gt \"${TOTALDB}\" ] ; then\r\n \techo Error : Unable to remove \"${DELNUM}\" DB Revision\\(s\\) as there are only \"${TOTALDB}\" DB Revision\\(s\\) remaining.\r\n \texit 1\r\n fi\r\n\r\n TOTALDBARRAY=$((${TOTALDB} - ${DELNUM}))\r\n VersionArray=($TOTALDBLIST)\r\n echo -n Are you sure you want to remove \"${DELNUM}\" from the current \"${TOTALDB}\" DB Revision\\(s\\) ? \\[Y\\\/N\\] ; read input\r\n case $input in\r\n y ) \r\n ;;\r\n Y ) \r\n ;;\r\n n ) \r\n exit 0\r\n ;;\r\n N ) \r\n\texit 0\r\n ;;\r\n * ) \r\n exit 0\r\n esac\r\n\r\n dbver -m delete `for ((j=0; j < ${#VersionArray[@]} - ${TOTALDBARRAY} ; j++)) ; do echo -n ${VersionArray[j]}, ; done` > \/dev\/null\t\t\r\n \r\n if [ $? == 0 ] ; then\r\n \techo Successfully removed \"${DELNUM}\" DB Revision\\(s\\).\r\n else \r\n \techo Error : Return Code $?.\r\n fi\r\n echo\r\n}\r\n\r\ndelete_before()\r\n{\r\n TOTALBEFORE=`list | awk ' NR>3 { print $2 } ' | grep -B10000 ${DELBEFORE} | wc -l | sed 's\/^ *\/\/g'`\r\n\r\n if [ \"${TOTALBEFORE}\" -eq \"0\" ] ; then\r\n \techo Error : Incorrect Database Revision ID supplied.\r\n \texit 1\r\n fi\r\n\r\n TOTALDBARRAY=$((${TOTALDB} - ${TOTALBEFORE}))\r\n VersionArray=($TOTALDBLIST)\r\n echo -n Are you sure you want to remove the Database Revision \"${DELBEFORE}\" and all Revisions before? \\[Y\\\/N\\] ; read input\r\n case $input in\r\n y ) \r\n ;;\r\n Y ) \r\n ;;\r\n n ) \r\n exit 0\r\n ;;\r\n N ) \r\n\texit 0\r\n ;;\r\n * ) \r\n exit 0\r\n esac\r\n\r\n dbver -m delete `for ((j=0; j < ${#VersionArray[@]} - ${TOTALDBARRAY} ; j++)) ; do echo -n ${VersionArray[j]}, ; done` > \/dev\/null\t\r\n \r\n if [ $? == 0 ] ; then\r\n \techo Successfully removed \"${TOTALBEFORE}\" DB Revision\\(s\\).\r\n else \r\n \techo Error : Return Code $?\r\n fi\r\n echo\r\n}\r\n\r\nusage()\r\n{\r\ncat << EOF\r\nusage: dbdel [-d number | -b id_number | -s | -c | -l ]\r\nList, count and remove multiple database revisions\r\n\r\n -d number of db revisions to remove\r\n -b \t remove this db revision id and all before\r\n -s \t size of all DB Revisions\r\n -c count DB Revisions\r\n -l list DB Revisions\r\n -? usage\r\n\r\nEOF\r\n}\r\n\r\n\r\n### MAIN ###\r\n\r\nwhile getopts \"d:b:slc?\" OPTION\r\ndo\r\n case $OPTION in\r\n d)\r\n DELNUM=$OPTARG\r\n\t delete\r\n exit\r\n ;;\r\n\t b)\r\n\t DELBEFORE=$OPTARG\r\n\t delete_before\r\n\t exit\r\n ;;\r\n\t s)\r\n\t echo Total size of all DB Revisions = \"${TOTALSIZE}\"\r\n\t echo\r\n\t exit\r\n ;;\r\n l)\r\n\t list\r\n exit\r\n ;;\r\n c)\r\n echo Total number of Database Revisions = \"${TOTALDB}\"\r\n echo\r\n\t exit\r\n ;;\r\n\t ?)\r\n usage\r\n exit\r\n ;;\r\n esac\r\ndone\r\n\r\nusage\r\nexit 0\r\n<\/pre>\n
[Expert@sc-manger]#cat > dbdel\r\n\u00a0\r\n<-- paste script -->\r\n\u00a0\r\n[Expert@sc-manger]#chmod +x dbdel\r\n[Expert@sc-manger]#mv dbdel $FWDIR\/bin<\/pre>\n
[Expert@sc-manger]# dbdel ?\r\nusage: dbdel [-d number | -b id_number | -s | -c | -l ]\r\nList, count and remove multiple database revisions<\/pre>\n
\n-b \u00a0\u00a0\u00a0\u00a0 remove this db revision id and all before
\n-s \u00a0\u00a0\u00a0\u00a0 size of all DB Revisions
\n-c\u00a0\u00a0\u00a0\u00a0\u00a0 count DB Revisions
\n-l\u00a0\u00a0\u00a0\u00a0 \u00a0list\u00a0 DB Revisions
\n-?\u00a0\u00a0\u00a0\u00a0\u00a0 usage<\/p>\n[Expert@sc-manger]#\u00a0 dbdel -c\r\nTotal number of Database Revisions = 13<\/pre>\n
[Expert@sc-manger]# dbdel -d 632\r\nAre you sure you want to remove 632 from the current 732 DB Revision(s) ? [Y\/N]y\r\nSuccessfully removed 632 DB Revision(s)<\/pre>\n
[Expert@sc-manger]# dbdel -b 122\r\nAre you sure you want to remove the Database Revision 122 and all Revisions before? [Y\/N]\r\nSuccessfully removed 122 DB Revision(s)<\/pre>\n
[Expert@sc-manger]# dbdel -s\r\nTotal size of all DB Revisions = 4.2M<\/pre>\n
[Expert@sc-manager]# dbdel -l\r\n ----------------------------------\r\n\u00a0| ID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Date\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n\u00a0----------------------------------\r\n\u00a0| 61 | Fri Oct\u00a0 2 11:05:21 2009 |\r\n\u00a0| 62 | Tue Nov 17 11:04:23 2009 |\r\n\u00a0----------------------------------<\/pre>\n