A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Backup your database!

  1. #1
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581

    Backup your database!

    I'm working on a website for my sailing club, and on that website there are about 325 pictures. The pictures are in different albums, but are all in the same folder on the server. To organize the pictures, I have database where the path to the file, description and so on is stored.

    The problem was that the pictures had the name they were given by the person uploading them. This meant that when you uploaded something from your camera, it would be called DSC9123.jpg or something. A few of the pictures were overwritten, because they had the same name, and pictures with space in the name were not shown properly. To fix this I decided to rename all the pictures to img1.jpg, img2.jpg and so on, based on their index in the database.

    I wrote a PHP script that would copy the files from one folder to another, rename it, and update the database. It did this for every picture in the database. But when I ran the script, I got an error for every picture, because I had written the path wrong (I forgot a /, so it couldn't find the pictures).

    This means that I now have 325 pictures in a folder, with their original name, and 325 records in the database, with the new names of the pictures. And since I didn't backup the database, I have no way of restoring the photo album

    Anyone else have a story to share, or a shoulder I can cry on

  2. #2
    the friendly canadian DaVulf's Avatar
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,017
    Can't you run an update query adding in the / ?

    Yea, now that I think about it, just export that column to excel or something, run a find and replace for the path, replace it with the correct path, and re-import it.

  3. #3
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    But I have no idea which pictures go where. The database records have a field called img, which is the path to the picture. It used to be "images/pictureOfBoat.jpg", and in the images folder, there was a file called pictureOfBoat.jpg. But now the database records got "images/img1.jpg" in the img field, while in the folder the files still have their old name, pictureOfBoat.jpg.

  4. #4
    Former Employee of Satan Napalm's Avatar
    Join Date
    May 2000
    Location
    Stellenbosch, South Africa
    Posts
    561
    At my first company we did a database for a stock exchange. Cleverly the developer included a piece of code that SMS'd someone at the exchange if a single record was missing. He then deployed the db to a wrong place, so that, according the system, 300k records were missing. As you might imagine the person at the exchange who received the SMS' wasn't pleased.
    Never underestimate the power of stupid people in large groups

  5. #5
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    We had a phone call confirm system which we were testing. So, the orders would queue up and then one at a time, the contact number would be phoned and a PC-voice program would tell you what you bought or sold.

    Running the script to test (supposedly only once) resulted in an endless loop of phone calls calling my line. When my 4 lines filled up, it started bouncing to other phones in the company...the machine queued up about 5,000 phone calls before we could figure out how to gracefully stop the script - the machine was very old and could not handle a hard reboot.

    Phones ringing, bouncing, speaker phone, etc. The best was...once an incoming call had bounced twice we had an alarm on the wall which would ring a schoolbell type ring and blink lights to tell someone to pick up the damn phone. Everyone went bonkers...eventually, we all laughed once the loop was ended.

    That was the first and last time we tested that system.

    RH

    p.s. - why on earth would you run a script like that without testing it first?
    "Why does it hurt when I pee?" -- F. Zappa |

  6. #6
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    Haha, I'm not the only one then

    I don't know why I didn't test it, probably because I had backed up all the pictures to my computer, so I wasn't afraid of loosing them.

    I just found out that I could use the last-modified time of the file and the date field in the records to match the files. It worked for about 75 percent of the pictures, which is good enough. Now I have a lot of detective work ahead of me, trying to figure out which picture goes where

  7. #7
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    word to the wise. if you have a php form that sends you email, make sure you add your domain and the server IP to your spam filter's white list! if you use a third party exchange host, find out if they are using yet another 3rd party spam filter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center