1 (edited by Marc Paré 09/16/2015 10:25:28 am)

Topic: Restoring from Backup

I am not sure what I am doing wrong. I am new to FrontAccounting.

I had created my company and wanted to roll-back to a previous backup. For some reason, the restore took a very long time ... which never happened when I tested FrontAccounting.

So, I created a new company with the same name, but the original company had the "Table Pref: 1 and now the new company has the "Table Pref:2"

When I try to restore from my backup, it doesn't seem to work. I made sure the fiscal years matched. But, I wonder, when a backup is restored, should it not restore ALL of the files, regardless of the previous database table pref or fiscal years? Should it not just overwrite all?

In my case, it does seem to overwrite anything and my new copy of the company is empty of data (or at least I can't seem to see any).

Any ideas?

Just to add, if the issue is that I need to have the same "Table Pref: 1" as the original company, how would I reset FrontAccounting to allow me to create a new company, but going back to "Table Pref: 1" ... where would I be able to change the database file to reset the numbering count for "Table Pref"?

Marc

Re: Restoring from Backup

In phpMyAdmin or SQLyog or any MySQL client, drop your FA database (or delete the 1_ prefixed tables in a shared db) for the said company. Recreate the database for the 1_ company. Now get your extracted sql file from your earlier backup and load it into the newly created database.

If you still have any problems, PM me with the access details and a link to your backup.

Re: Restoring from Backup

Thanks for the quick reply.

I am going to treat this as a learning exercise for myself and try to understand how to fix.

I have now created 4 more companies and can no longer pick "Table Pref: 1" from the admin setup tab -- "Create Update company". When I now click on the "Table Pref:" it will only let me choose "6" as the "Table Pref". If I drop all of the tables except of course for "0" does this then reset the "Table Pref" to "1"?

Is there a way to force a "Create" to a particular "Table Pref" number? My backup was done on a table prefix of "1".

Marc

4 (edited by apmuthu 09/16/2015 05:43:08 pm)

Re: Restoring from Backup

Are you trying to create all the companies using the same database? Only if you have a separate database for each company, can you choose whatever prefix you want for each company. Any companies you delete can also have them removed from the config_db.php file as well.

Re: Restoring from Backup

Yes, the companies are all on the same database. All three are related to music groups and, to keep the number of databases down on my shared server, they need to share the same database -- I do not have many more number of MySQL database left on my host service.

For now, I have re-installed FA and restored the Backup.

However, here is an example to demonstrate the issue I see with the restoration process with FA.

IF ...

* a FA user creates (let's say) 3 FA accounts on one database with the table-prefixes of "0", "1", and "2"
* and then has issues with a damaged FA account "1" and is forced to erase it (so the FA account table-prefix "1" is now erased
* it does not look like there is an easy way of restoring that account "1" as the FA restoration process will only allow you to restore databases that still exist
* in addition FA will only let you create a database account with a table-prefix of "x+1" (starting from the last prefix number) ... so in this case, the only option in creating an account is to create a FA database table-prefix of "3" and not "1" -- FA will not allow the creation of a database table-prefix of "1", but will only allow the creation of a new database account with a table-prefix of "4"
* FA does not allow you to create a database with a table-prefix of "1", so, that the user is able to restore the table-prefix "1".

I suspect the only way to fix this example would be to create a new FA database account with table-prefix "4", do the restoration of the backup of the table-prefix "1" account and then go into the database and physically change the table-prefix name of each table by hand to "4" so that the information may then be used with the new FA account table-prefix "4".

In my case, for example, it was easier to delete my database (with all 3 companies with table-prefix "0", "1", and "2"), recreate the same 3 companies in the right order and then restore all from my backups

I am wondering if there could be a more elegant way of allowing the FA user to recreate a FA account with a table-prefix that is less than what FA normally allows? Or another way, would be for FA, when asked to create a company, it would scan the table-prefixes in use and if there are any gaps in "free" prefixes, then FA could allow the user to create a company with these prefixes as well as the usual "x-last-prefixused + 1" formula.

Sorry if this all sounds confusing. Let me know if you need me to make my example clearer or if you can see any other way of solving such a situation.

Thanks for your help and patience ... FA is a wonderful piece of software!

Cheers,

Marc

Re: Restoring from Backup

When companies are deleted out of order as is in practice, finding a missing prefix in the array would clash with possible non numeric table prefixes and the possiblility of restoring from a deleted company into it's original prefix.

When a new company is created, an entry is made in the config_db.php table for it. This entry contains the prefix to be used and the key for the entry need not be the same as the prefix used.

1. Create your 3 companies anew so you have 0 (Default), 1,2,3 companies.
2. Note down the config_db.php entries (backup the file).
3. Delete company with prefix 1_.
4. The entry for the company "1" is removed from the config_db.php file
5. The value of the variable $tb_pref_counter in the config_db.php will signal the next prefix - alter it as needed even temporarily so as to create your company "1" again and then revert back.

Re: Restoring from Backup

Thanks! Nice to know this and really helps.

Thanks again for all of your wonderful help.

Marc

Re: Restoring from Backup

Wiki-ed it.