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.

Need help in backing up of databases.

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

  1. sreepriya0987

    sreepriya0987 Registered

    Joined:
    Jan 16, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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.

    Thanks,
    Sreepriya
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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?
     
  3. hostmedic

    hostmedic Well-Known Member

    Joined:
    Apr 30, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    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 SourceForge.net
     
Loading...

Share This Page