Bacula-users

[Bacula-users] Job renaming

2011-02-10 03:41:43
Subject: [Bacula-users] Job renaming
From: Marcello Romani <mromani AT ottotecnica DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 10 Feb 2011 09:39:22 +0100
Hallo,
     I found a typo in a Job resource that has been backed up for a 
couple of weeks, so I wanted to rename it. Here are the steps I took. I 
hope it will be useful to somebody else.
Bacula gurus feel free to burn me if this is heresy :-)

References:
http://www.mail-archive.com/bacula-users AT lists.sourceforge DOT 
net/msg20479.html

Let's call the job Mailserver and suppose the misspelled name is 
Malserver (missing 'i').

The database server is postgresql.

- stop bacula-director to avoid catalog modifications while we are 
working on it;

- backup the catalog (e.g. with mysql or postgresql dump tools), just in 
case;

- rename the job in the bacula-dir config file;

- connect to bacula database directly via db console (psql in my case)
   The table we'll work on is named "job".
   The columns that we have to modify are "job" and "name".
   The jobhist table should also be checked: if it has records, the 
procedure should be applied there too.

- count the number of records to be modified (just to check the update 
command)
bacula=# SELECT COUNT(*) FROM job WHERE name='Malserver';
bacula=# SELECT COUNT(*) FROM job WHERE job LIKE 'Malserver%';
You should get the same number of records.

- update the name column
bacula=# UPDATE job SET name='Mailserver' WHERE name='Malserver';

- update the job column
bacula=# UPDATE job SET job=replace(job, 'Malserver', 'Mailserver') 
WHERE job LIKE 'Malserver%';

The two update commands should modify the same number of rows counted 
before.

- Check the jobhist row count and apply the rename procedure if it's not 
zero.

- restart the director

The misspelled job name will remain unchanged in the "terminated jobs" 
section of the status command, both on the director and on the client 
nodes (*-fd). That's because that information is stored into status 
files and not into the database.


- Test table
Before applying the update commands to the actual catalog, I tested them 
on a temporary table. To create and populate it with the actual records, 
I used the following commands:
bacula=# CREATE TABLE test_rename(jobid integer, job text, name text);
bacula=# INSERT INTO  test_rename(jobid, job, name) SELECT jobid, job, 
name FROM job;
Obviously a DROP TABLE test should be issued at the end of the rename 
procedure.

HTH

-- 
Marcello Romani

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>