Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Need help in backing up of databases.

Discussion in 'Database Discussion' started by sreepriya0987, Jan 16, 2012.

  1. sreepriya0987

    sreepriya0987 Registered

    Jan 16, 2012
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hi Everyone,

    I am new to DBA stuff. I wonder if anyone can help me. Task is that, I have 10 databases and need to take backups of all the databases using data pump in Unix/Linux, compress them using gzip and use cron to schedule the job twice a day.

    Appreciate if anyone can help me in this. I was trying this for a week but no luck.

  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Oct 2, 2010
    Likes Received:
    Trophy Points:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    What have you done so far command wise so we know what parts are and are not working?
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. hostmedic

    hostmedic Well-Known Member

    Apr 30, 2003
    Likes Received:
    Trophy Points:
    Washington Court House, Ohio, United States
    cPanel Access Level:
    DataCenter Provider
    Well - backing up one time is pretty simple - as long as you know your mysql user/pass (depending on your setup you may not need that from the command line either... )

    To backup a single database via SSH - simply do the following @ the command line (cli)

    mysqldump --add-drop-table -u db_username -p db_name > mybackup.sql
    (Omit the –add-drop-table argument if you’ll want to merge this backup with an existing database upon restore)
    (Replace db_username with the name of your database user )
    (Replace db_name with the name of your database )
    (Replace mybackup.sql with the name of your backup file )

    Another alternative would be to do each together - I have used this in the past - and simply set to perform daily via a cron job

    * * * * * mysqldump -u root -pPASSWORD --all-databases | gzip > /filepathhere/database_`data '+%m-%d-%Y'`.sql.gz

    of course you could always run that from the command line as well - be sure to change the /filepathhere/ to where you want it to go.

    Now - If you are looking for a much better backup approach however I suggest using a script called AutoMySQLBackup has all the features most need:

    1. simple database backup
    2. multiple database backups
    3. ability to compress (gzip or bzip2) the backups to save on storage
    4. rotate backups to save space and cut down on old garbage.
    5. email when done/ logs etc ...

    The installation is very simple: just download the one file bash script and save it somewhere, customize it to fit your setup (only some basic changes are needed: like the MySQL user and password, backup location), make it executable and activate it in cron as needed (daily for example).

    Check out the FREE project on sourceforge AutoMySQLBackup | Free software downloads at
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice