I think your request does have merit.
If you want to roll your own solution until the developers can consider your request, I think I have a path. Its not difficult to do (of course it helps to know what you are doing).
- You need to export the image definitions from your master FOG server. The following command will export your images table.
mysql -u root -e "SELECT imageName,imageDesc,imagePath,imageProtect,imageMagnetUri,imageDateTime,imageCreateBy,imageBuilding,imageSize,imageTypeID,imagePartitionTypeID,imageOSID,imageFormat,imageLastDeploy,imageCompress,imageEnabled,imageReplicate,imageServerSize FROM images WHERE imageReplicate='1';" fog | tr '\t' ',' > /tmp/imageimport.csv
Note there is another way to do the same thing. If you run into issues with this command we can use option 2.
-
Move the /tmp/imageimport.csv
file to your remote fog server using the scp command (hint: this all can be scripted into a cron job).
-
On the remote fog server you need to create an imageimport table (once) in your fog database. Key in the following command mysql -u fog
. Then paste in the following command into the mysql command console.
CREATE TABLE imagesimport (
imageName varchar(40),imageDesc longtext,imagePath longtext,imageProtect mediumint(9),imageMagnetUri longtext,imageDateTime timestamp,imageCreateBy varchar(50),imageBuilding int(11),imageSize varchar(255),
imageTypeID mediumint(9),imagePartitionTypeID mediumint(9),imageOSID mediumint(9),imageFormat char(1),
imageLastDeploy datetime,imageCompress int(11),imageEnabled enum('0','1'),imageReplicate enum('0','1'), imageServerSize bigint(20) );
exit;
- On the target FOG server create the following file
importimages.sql
. This will be the sequences of commands to execute to import the exported csv from the master server into the imageimport table.
DELETE FROM imagesimport;
LOAD DATA INFILE "/tmp/imageimport.csv"
INTO TABLE imagesimport
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
- This next section will be appended to the above section in the
importimages.sql
. There is a lot going on here so I thought I need to explain it. First it collects a list of imageNames in the imageimport table not in the images table. This is done, because we only want to import new records into the destination FOG server. Once we have that list only those records are imported into the images table.
INSERT INTO images (imageName,imageDesc,imagePath,imageProtect,imageMagnetUri,imageDateTime,
imageCreateBy,imageBuilding,imageSize,imageTypeID,imagePartitionTypeID,imageOSID,imageFormat,
imageLastDeploy,imageCompress,imageEnabled,imageReplicate,imageServerSize)
SELECT imageName,imageDesc,imagePath,imageProtect,imageMagnetUri,imageDateTime,imageCreateBy,imageBuilding,
imageSize,imageTypeID,imagePartitionTypeID,imageOSID,imageFormat,imageLastDeploy,imageCompress,
imageEnabled,imageReplicate,imageServerSize
FROM imagesimport
WHERE imageName NOT IN (SELECT imageName FROM images);
- This last part will update the image definitions in the images table with matching records in the imageimport table. This way any updates made in the master fog server will be updated in the remote fog server.
UPDATE images i, imagesimport m
SET i.imageDesc = m.imageDesc,
i.imagePath = m.imagePath,
i.imageProtect = m.imageProtect,
i.imageMagnetUri = m.imageMagnetUri,
i.imageDateTime = m.imageDateTime,
i.imageCreateBy = m.imageCreateBy,
i.imageBuilding = m.imageBuilding,
i.imageSize = m.imageSize,
i.imageTypeID = m.imageTypeID,
i.imagePartitionTypeID = m.imagePartitionTypeID,
i.imageOSID = m.imageOSID,
i.imageFormat = m.imageFormat,
i.imageLastDeploy = m.imageLastDeploy,
i.imageCompress = m.imageCompress,
i.imageEnabled = m.imageEnabled,
i.imageReplicate = m.imageReplicate,
i.imageServerSize = m.imageServerSize
WHERE i.imageName = m.imageName
- The last bit is to run this command to execute the script
mysql -u root fog < importimages.sql
A cron job on the remote computer can call this import function.
This whole idea is this.
- On the master FOG server at 6pm a cron job runs to export the images table to a cvs file. Then the file is copied to the remote fog server using scp or ftp.
- On the remote FOG server at 6:15p a cron job runs to import the image csv file into the imagesimport table and then update the images table on the remote fog server.
I know this seems like a lot for a DIY solution. It may be beyond what you are really looking for.