The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

database backup

Discussion in 'General Discussion' started by albertldee, Oct 7, 2003.

  1. albertldee

    albertldee Member

    Joined:
    May 10, 2003
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    hi everyone
    is it possible to use cron jops to do a phpMyadmin backup of my database name pbforums, please if possible can i get some instruction how to make it possible i just lost my database the other day when mu host server went down

    thanks

    cPanel.net Support Ticket Number:
     
  2. Jemshi

    Jemshi Well-Known Member

    Joined:
    Sep 11, 2003
    Messages:
    210
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    what do you mean by phpMyAdmin backup ?. If you want to take backup of your database, use a small script and run it in cron.

    #!/bin/bash
    mysqladmin -u username -ppassword databasename > /path/to/file.sql

    Add this script in your cron.

    ***: There is no space between -p and password.

    cPanel.net Support Ticket Number:
     
  3. albertldee

    albertldee Member

    Joined:
    May 10, 2003
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    this is what i enter on the command line

    #!/bin/bash mysqladmin -u username -ppassword dbname > /home/username/public_html/cronjobl/file.sql

    i create a folder name cronjob
    is this correct

    cPanel.net Support Ticket Number:
     
  4. albertldee

    albertldee Member

    Joined:
    May 10, 2003
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    is this correct it's not working for me
     
  5. brumie

    brumie Active Member

    Joined:
    Dec 9, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    create sh file, example mysql.sh in /home/username/backup

    content:

    Code:
    #!/bin/sh
    date=`date -I`
    mysqldump -u [COLOR=red]username[/COLOR] -p[COLOR=red]password[/COLOR] --opt --databases [COLOR=red]username_db1[/COLOR] [COLOR=red]username_db2[/COLOR] [COLOR=red]username_db3[/COLOR] [COLOR=red]username_db4[/COLOR] | 
    bzip2 -c > /home/username/backup/databasebackup-$date.sql.bz2
    
    this will create tar.bz2 filename based on date.
    username_db1, 2, 3, 4 represent what database/s you want to add it.

    save it and open cpanel add cronjob from there
    Code:
    sh /home/username/backup/mysql.sh
    
    note: don't put any spaces between -p and password
    -ppassword not -p password
     
  6. flash7

    flash7 Well-Known Member

    Joined:
    Feb 16, 2004
    Messages:
    203
    Likes Received:
    0
    Trophy Points:
    16
    That work if username have a shell account ;)
    thanx
     
  7. brumie

    brumie Active Member

    Joined:
    Dec 9, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    hmm i haven't test it but try this ;)
    create the sh script from your workstation, upload via ftp make it executable and login to cpanel, goto cronjob add it there to run it everytime on schedule
     
Loading...

Share This Page