#1
  1. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,969
    Rep Power
    374

    Data replication system. (for back up purposes)


    Hi

    So I create micro sites where users come, fill in their details which go to an external DB via API.

    Sometimes the API goes down and user data is lost. So I am thinking of a backup system whereby the user details are stored in a CSV file and then a cron job would look at these CSV every hour and submit them.

    Is this the best solution, are there any better suggestions?

    Each microsite will have its own unique key to identify in the external DB, username/pass and field names.
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,111
    Rep Power
    487
    CSV maybe not; a local database however, yes.

    If you're gonna store usernames / passwords or personal info, you can't just drop a .CSV into /tmp and hope that other users of the system aren't going to read it!

    You can then schedule a cron job to run a PHP script and read in/submit the credentials to the 3rd party api.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,969
    Rep Power
    374
    database might be hard. because each site may have different data requirements...

    funnily enough I have created a database & a cron job for slightly different project..
  6. #4
  7. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,111
    Rep Power
    487
    Well, for your DB, you don't store the data requirement information in different fields, keep them all in one, something like this:-

    tablePending
    ------------------
    id | client | requirements
    -------------------------------
    1 | badgerfruit corp | JSON Encoded list of their parameters
    2 | paulh and co | JSON Encoded list of their parameters
    ...
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984

IMN logo majestic logo threadwatch logo seochat tools logo