Command or Script to add text to parameter 'shutdownhtml' in param file.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Command or Script to add text to parameter 'shutdownhtml' in param file.

cthoong
Hi,

I am looking for One Line Command or a simple script to set the 'shutdownhtml' in /var/www/html/bugzilla/data/param file.

From...

           'shutdownhtml' => '',

To....

           'shutdownhtml' => 'Archiving DB and Bugzilla config... It could takes 5 min or longer.',

Did try to use "sed" but somehow the config above has Single Open quote ' , so seem like "sed" not able to do this... ??

Thanks for helping.

Reply | Threaded
Open this post in threaded view
|

Re: Command or Script to add text to parameter 'shutdownhtml' in param file.

Thorsten Schöning
Guten Tag cthoong,
am Donnerstag, 16. Mai 2013 um 11:31 schrieben Sie:

> Did try to use "sed" but somehow the config above has Single Open quote ' ,
> so seem like "sed" not able to do this... ??

The config needs to be valid Perl code, this may help you to find a
solution. You could alternatively simply store two configuration
files, one with the shutdown text, the other without and move them as
needed into place. This would have the benefit that the operations are
atomic and you don't have to deal with requests which get broken
configuration data simply because they arrive in the moment were you
save the new file with the new contents and have some milliseconds of
invalid perl code.

Said that, why do you think you have to shutdown your Bugzilla
installation at all? It's surely not needed for backups of your
database as all modern databases are able to do a backup while they
are running. Changes to the file system can only occur because
administrators change the system configuration, which won't happen
very often, if users upload some attachments and you configured to
store them in the file system and by running scripts like
collectstats.pl. Depending on your configuration all of those may not
be a problem for you and you don't need to shutdown your
installation.

Depending on your file system you should consider using snapshots,
too.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail:[hidden email]
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Command or Script to add text to parameter 'shutdownhtml' in param file.

cthoong
Guten Tag Thorsten Schöning,

You really think out of the box while I was only struggling "one line command"...

As if replacing by another "param" file with "shutdownhtml" text, there's chance that could forget to use the correct "param" file when come to restoration in future. Having said that, it's one of the quick solution !!!!

But I think I will look at perl script first to see how to modify it by running a perl script to modify the "param" file. If i make it, I will put up the script here.

The reason why I am looking for put up the text, is because of many forum has advised to put up the "shutdownhtml" text before backup, even from mozilla...

https://wiki.mozilla.org/Bugzilla:Move_Installation

1. Shut down your Bugzilla by going to the Parameters page (under "Administration") and putting some text into the "shutdownhtml" parameter. (In Bugzilla 3.6 and later, this is in the "General" section of the Parameters. In earlier versions it will be on the first page when you open the Parameters screen.)
............

Anyway, I didn't config to use file system to store any attachment but solely using Mysql.

Thank you Thorsten Schöning !!
Reply | Threaded
Open this post in threaded view
|

Re: Command or Script to add text to parameter 'shutdownhtml' in param file.

Thorsten Schöning
Guten Tag cthoong,
am Montag, 20. Mai 2013 um 06:39 schrieben Sie:

> As if replacing by another "param" file with "shutdownhtml" text, there's
> chance that could forget to use the correct "param" file when come to
> restoration in future. Having said that, it's one of the quick solution !!!!

You will have the same problem if you write shutdownhtml-text into
only one configuration file because this will always be the file you
backup, therefore during restores you will always have that text in
your configuration file and your restored Bugzilla will never work out
of the boy.

> But I think I will look at perl script first to see how to modify it by
> running a perl script to modify the "param" file. If i make it, I will put
> up the script here.

You don't need to do it with perl, I just wanted to notice that it
needs to be valid Perl code in the end because you wondered about the
single quotes. The following sed command worked for me, I replaced the
needed single quotes with regexp dot operator:

sed --regexp-extended 's/(.)shutdownhtml\1(\s+)=>(\s+)\1{2},/\1shutdownhtml\1\2=>\3\1someText\1,/' params > params.shutdown

Afterwards you need to move params out of place and rename
params.shutdown. What doesn't seem to work is something like
sed ... params > params, which resulted in an empty file.

> https://wiki.mozilla.org/Bugzilla:Move_Installation

This is a different scenario than backups only because on moving an
installation you have to make sure that no one uses the old
installation again or else you wouldn't ever now if it's save to
switch both installations and you surely have all old data in the new
installation and new data is only created in the new installation.
During normal backups you only need one point in time for consistent
data to create a backup and data created during or after the backup
process is simply backed up the next time. You always have data which
needs to be backed up the next time.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail:[hidden email]
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Command or Script to add text to parameter 'shutdownhtml' in param file.

cthoong
Guten Tag Thorsten Schöning,

You are right, it's expected that have to remove the "shutdownhtml" text when come to restore as it was being set during archive. This is ok as I will put it down on restoring steps.

"Move_Installation" fit what I want as I intend to make archive to restore in new Bugzilla (in the case of existing Bugzilla server is totally gone).

I was studying Perl from beginning starts form yesterday, I believe will take more than more than a week time to do the same thing.

So... really have to SALUTE to your one line command !!! This has making the backup script more robust.

Below is the complete archive shell script:
--------------------------------------------------------------------------------------------------
#!/bin/sh
# Script for backup Bugzilla configuration files and DB

# Setting up path and filenames
echo "#######################################" >>/var/log/bugzilla_backup.log
echo "$(date)" >>/var/log/bugzilla_backup.log
mydate=$(date +%Y%m%d)
echo "$mydate - Backup process starts -- The following logs doesn't means no error during backup as error log will not print out in this log files." >>/var/log/bugzilla_backup.log

backup_folder_path="/home/bugzilla/backup"
echo "1. Setting backup_folder_path = $backup_folder_path" >>/var/log/bugzilla_backup.log

mysql_db_bck_path_filename="$backup_folder_path/bugzilla_db_$mydate.bck.sql"
echo "2. Setting mysql_db_bck_path_filename = $mysql_db_bck_path_filename" >>/var/log/bugzilla_backup.log

bugzilla_folder_path="/var/www/html/bugzilla/"
echo "3. Setting bugzilla_folder_path = $bugzilla_folder_path" >>/var/log/bugzilla_backup.log

bugzilla_files_bck_path_filename="$backup_folder_path/bugzilla_files_$mydate.bck.tgz"
echo "4. Setting bugzilla_files_bck_path_filename = $bugzilla_files_bck_path_filename" >>/var/log/bugzilla_backup.log

# Shutting down Bugzilla by adding text to 'shutdownhtml' in "params" config file in 3 steps.

# Step 1 - Duplicate "param" file with adding 'shutdownhtml' text and save to name "params.shutdown".
# --- DO NOT put the output name as same as "params", this will erase all the data in param!!! ---
sed --regexp-extended 's/(.)shutdownhtml\1(\s+)=>(\s+)\1{2},/\1shutdownhtml\1\2=>\3\1Bugzilla is under maintanance now, could take couples of minutes. Please retry after 5 minutes.\1,/' $bugzilla_folder_path/data/params > $bugzilla_folder_path/data/params.shutdown

# Step 2 - Backup origianl "params" file.
mv $bugzilla_folder_path/data/params $bugzilla_folder_path/data/params.org

# Step 3 - Change to use "params"
mv $bugzilla_folder_path/data/params.shutdown $bugzilla_folder_path/data/params
echo "5. Blocking changes to Bugzilla by adding text to 'shutdownhtml' in param config file." >>/var/log/bugzilla_backup.log

# Dump DB data
mysqldump -uroot -pbugzilla bugs > $mysql_db_bck_path_filename
echo "6. Backup DB 'bugs'" >>/var/log/bugzilla_backup.log

# Compression
gzip -f9 $mysql_db_bck_path_filename
echo "7. Compress DB backup file '$mysql_db_bck_path_filename'" >>/var/log/bugzilla_backup.log

# Backup bugzilla config files
tar -cvzf $bugzilla_files_bck_path_filename $bugzilla_folder_path
echo "8. Backup '$bugzilla_folder_path' to '$bugzilla_files_bck_path_filename'" >>/var/log/bugzilla_backup.log

# Restore back the original param file setting without 'shutdownhtml' text.
mv -f $bugzilla_folder_path/data/params.org $bugzilla_folder_path/data/params
echo "9. Restore back the param file, turned on Bugzilla." >>/var/log/bugzilla_backup.log

echo "10. DB and Files backup process ends." >>/var/log/bugzilla_backup.log
echo "------------------" >>/var/log/bugzilla_backup.log
--------------------------------------------------------------------------------------------------

Can also do it the other way round with using "-i" to edit the params file instead of output to new file:
1. Backup the params file before edit.
    cp params params.org

2. Edit the params file directly.
    sed -i --regexp-extended 's/(.)shutdownhtml\1(\s+)=>(\s+)\1{2},/\1shutdownhtml\1\2=>\3\1someText\1,/' params

3. After archive completed, restore back the params.
    mv -f params.org params

Can close case finally.

Thank you Thorsten Schöning !