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 !
--
View this message in context:
http://mozilla.6506.n7.nabble.com/Command-or-Script-to-add-text-to-parameter-shutdownhtml-in-param-file-tp279974p280310.html