SearchSearch   ProfileProfile   Log inLog in   RegisterRegister 

Automatic backup of user database ?

 
Post new topic   Reply to topic    FirstSpot Forum Index -> Pre-sales Support Forum
View previous topic :: View next topic  
Author Message
mfleury



Joined: 02 Jan 2006
Posts: 11

PostPosted: Fri Jan 11, 2008 5:59 pm    
Post subject: Automatic backup of user database ?

Hello to all happy users of firstspot,

I look for a way to make the export of the users database to the userdata.csv file automatic (like when you click on "export all" on the users tab).
The idea is to have a program exporting it automatically, let say, every 24 hours.
Command line, or any specific program, any idea would be more than welcome.

Thanks a lot

Matthieu, from Tahiti
Back to top
gsgriffin



Joined: 25 Jun 2007
Posts: 54

PostPosted: Thu Jan 17, 2008 1:57 pm    
Post subject: Mattieu, first get me to Tahiti!!!!!

Mattieu,

You bring up a good request and one that I just said to myself, "of course, why am I not doing that!" I adapted the script and put in a couple little notes that you can adjust if you want it to do something slightly different.

In short, put this script into its own file your cnfmgr folder. Save the file as anything you want .php. Call up the script through IE and windows scheduler. The script will run through and backup your user info immediately and then done. Just in case, call it at http://localhost:5787/whatever.php

Keep in mind that anyone logged into your system that can figure out the port of 5787 can run this script. That may not be a big security risk, but it is not password protected like the rest of the cnfmgr files. That is on purpose so you don't have to log in.


<?php

include_once("..\\authserv\\common_functions.php");

$settingobj = new COM('FSCONFIG.Cfgmgr') or die('settingok.php FSCONFIG.Cfgmgr Object cannot be created!');
$Datasource_Tablename=$settingobj->getKey('Datasource_Tablename', 'gateway');
$Datasource_Plans_Tablename=$settingobj->getKey('Datasource_Plans_Tablename', 'gateway');
$Datasource_PayPal_Table=$settingobj->getKey('Datasource_PayPal_Table', 'gateway');
$Datasource_Url_Tablename=$settingobj->getKey('Datasource_URL_Log_Tablename', 'gateway');
//free COM object
$settingobj->Release();
$settingobj=null;

//*******************************************************************************************************************
// Change the following value to whatever you desire to be exporting
$table='user';
//I wouldn't advise making the import function automatic. Doing so with the program running can and will cause corruption to the Db
//allow only one of the following lines to run. $export will export only the file as you designate in the line above. Export all will backup all user, plan, cc, and url data at the same time
$export='true';
$exportall='true';

if (isset($table) && $table == 'user')
$exportImportFile='userdata.csv';
if (isset($table) && $table == 'plan')
$exportImportFile='plandata.csv';
if (isset($table) && $table == 'cc')
$exportImportFile='ccdata.csv';
if (isset($table) && $table == 'url')
$exportImportFile='urldata.csv';

if (isset($export)) {
if (isset($table) && $table == 'user')
$Datasource = $Datasource_Tablename;
if (isset($table) && $table == 'plan')
$Datasource = $Datasource_Plans_Tablename;
if (isset($table) && $table == 'cc')
$Datasource = $Datasource_PayPal_Table;
if (isset($table) && $table == 'url')
$Datasource = $Datasource_Url_Tablename;

$msg = exportDB($exportImportFile, $table, $Datasource);
} else if (isset($exportall)) {
$table = 'user';
$exportImportFile='userdata.csv';
$Datasource = $Datasource_Tablename;
$msg = exportDB($exportImportFile, $table, $Datasource);
$table = 'plan';
$exportImportFile='plandata.csv';
$Datasource = $Datasource_Plans_Tablename;
$msg .= '<br>'.exportDB($exportImportFile, $table, $Datasource);
$table = 'cc';
$exportImportFile='ccdata.csv';
$Datasource = $Datasource_PayPal_Table;
$msg .= '<br>'. exportDB($exportImportFile, $table, $Datasource);
$table = 'url';
$exportImportFile='urldata.csv';
$Datasource = $Datasource_Url_Tablename;
$msg = '<br>'. exportDB($exportImportFile, $table, $Datasource);
}
echo $msg;
?>


<script type='text/javascript'>
self.window.close()
</script>
_________________
Greg
Back to top
mfleury



Joined: 02 Jan 2006
Posts: 11

PostPosted: Fri Jan 18, 2008 5:04 pm    
Post subject:

Hey Greg, thanks a lot, i'm going to try that really fast !

Best Regards,

Matt
Back to top
mfleury



Joined: 02 Jan 2006
Posts: 11

PostPosted: Tue Jan 29, 2008 8:28 am    
Post subject: Export /import

I would know how to import the csv file as well.
Back to top
gsgriffin



Joined: 25 Jun 2007
Posts: 54

PostPosted: Mon Feb 04, 2008 9:03 am    
Post subject: Do that in the Config Mgr

I wouldn't try to automate the importing of the CSV. Go to the Config Mgr and login. Go to the Users tab and scroll down to the bottom. There is a database selection box and then import/export buttons. Find the CSV you want to import and then click IMPORT. Make sure that the CSV is in your main FirstSpot folder. That is where it will automatically look.
_________________
Greg
Back to top
Display posts from previous:   
Post new topic   Reply to topic    FirstSpot Forum Index -> Pre-sales Support Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group