Do you ever though about creating a backup copy of your domains in GlassFish , for example before doing something unpredictable , meanwhile you like your domain because of its configurations ?
here is simple steps to create backup and restore those backup.
before we go any further you should know , domaindir that we see in many of asadmin commands has a default value its default value is : GlassFish_home/domains , in all of those commands that has domaindir parameter, if you explicitly do not identify the domaindir asadmin will use the default values. So , when you use domain1 in some command , asadmin will look inside GlassFish_home/domains for that particular domain. steps to create a backup :
Execute asadmin from bin directory under GlassFish_home
in case that you want to create a backup from a domain named domain1 (which is default domain)
execute : backup-domain --description "I made this backup before changing default domain descriptor" domain1
after you execute this command , asadmin will create a folder named backups inside GlassFish_home/domains/domain1 and place a zip file there. The zip file is a backup of your domain . For example the zip file could be : sjsas_backup_v00001.zip it means that it is first backup that you create for this domain.
if you open the zip file you can see a file named backup.properties which contain informations like :
#Wed Apr 26 01:00:40 IRDT 2006
timestamp.human=Wed Apr 26 01\:00\:40 IRDT 2006
description=I made this backup before chaning default domain descriptor
There is a command which helps you to find out how much backups you have and shows you information related to each backup entry you made.This command is : list-backups it get an operand , the operand will be your domain name. You can also tell it that your domain dir is not the default place using --domaindir parameter.
Now lets see how we can restore this backup using asadmin administration console.
there is a command named restore-domain , this command will restore a domain using a backup file. Simply you need just to pass an operand which is your domain name. If you do this , it will restore your domain using your latest backup . So if I execute : restore-domain domain1 it will looks inside the backups folder (the default place) and select latest backup then it will try to restore the domain using that backup.
you can use --filename parameter to specify another backup file which should be passed using a full path.
I should say that this command accept domaindir parameter as other commands that we talked about them this time.