[ic] Export For Restore/Import

D Zhang - msi interchange-users@icdevgroup.org
Sun Feb 23 03:09:00 2003


----- Original Message -----
From: "Jon" <prtyof5@attglobal.net>
To: <interchange-users@icdevgroup.org>
Sent: Sunday, February 23, 2003 1:05 AM
Subject: [ic] Export For Restore/Import


>
>     Suggestions and possibly code for performing an export of all
> IC tables such that they can be easily imported back into IC.
> Prefer something in Perl so I can add a cron entry.
> Apologies if it is in the archives. I haven't had luck finding.
> I'm using IC 4.9.3
>
> Jon
>

I don't check the archieves either. But, it sounds a good idea.

I think a structure and flow below may do the job:

For export (backup)


1.  use cwd to read the products dir
2.  identify database tables by file extension such as sql, gbdm
3.  use the identified extension to determine how DBI should work.
4.  write all talbes to one single file in the following structure:

include date and time in file name

line 1: date and time the file is genrated.\n
line 2: table name\n
line 3: fields names\n
line 4: number of records\n
line 5: record 1\n       (tab delimited, same field sequence as the fields
names or cause)
....
line n: last record of the table\n

repeat line 2 to line n for each table till finished.

this file should be easilly put back to tables.

for impurt (write tables back)

skip first line (or can be used for check the correct file, compared with
file name or some how)

while (<>) {

  call a sub to do: {

     read second liine, determine DBI connection by file extention
     read third line to get field names
     read number of record.
     open and write to the file name
    a (for loop) to write the table.
  }

}


possible problem:
1  the file may became too large if the site is large
2. cpanel user may not be able to do due to file permision.


David
dzhang@msihosting.com
http://www.msihosting.com
Export -- ecommerce solution, interchange hosting