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 'Database Discussions' started by dsdeiz, Sep 27, 2010.

  1. dsdeiz

    dsdeiz Registered

    Joined:
    Sep 27, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hi!

    Um, we have this backup that is being done "per account" (which means per Cpanel account right?). What happens if the database wasn't created under any account? Is it possible? Where would the backup go?

    I noticed that whenever I create a new mysql user and database, the name of the account is always added at the beginning. The mysql user and database I am searching for don't have an account prepended to them so I'm having trouble tracking how it was created or where the backup went. :(

    Any things to consider?

    Thanks!
     
    #1 dsdeiz, Sep 27, 2010
    Last edited: Sep 27, 2010
  2. serlex

    serlex Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Do you have SSH access to the server? Try searching for the files using common Linux commands:

    find
    grep
    locate

    Regards,
     
  3. dsdeiz

    dsdeiz Registered

    Joined:
    Sep 27, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hi!

    Hm, I actually don't know where the backups from the previous machine are being stored. Is it somewhat set from somewhere?

    Thanks!
     
  4. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    If the backups were made using the cPanel backup system, the backup location would be configured in /etc/cpbackup.conf. Within the file, the following directive would set the location:

    Code:
    BACKUPDIR /backup
    The backups would be inside a cpbackup directory in the directory specified by the BACKUPDIR directive.

    If the backups were not done using the cPanel backup system, which appears unlikely since you indicate the database may not have been created via cPanel, then there is no way within cPanel to tell where the backup may be.

    From what you described, there is a strong possibility that the database was not backed up at all. The "Per Account Only" option for the backup configuration will only back up databases associated with each particular account, and databases not associated with any account would not be backed up.
     
  5. dsdeiz

    dsdeiz Registered

    Joined:
    Sep 27, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Oh okay. I'm not actually sure if it wasn't created via Cpanel. :D Um, if that was the case, then I guess the database files would just be stored on the datadir directory for mysql right? e.g. /var/lib/mysql

    Thanks!
     
  6. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    The database would be stored in MySQL's base directory, which by default is /var/lib/mysql. If a different base directory is used, it would be specified in /etc/my.cnf.

    I do not recommend simply copying the database files. While this can often work, the approved MySQL method is to create a dump, and use the dump to import the database on the "new" server. The basic syntax is the following on the "old" server:

    Code:
    # mysqldump yourdbname > yourdbname.sql
    This assumes that the MySQL root password is the same as the server's root password. If it is not, specify the root user and the option to enter a password:

    Code:
    # mysqldump -uroot -p yourdbname > yourdbname.sql
    It is the same command, but you will be prompted for the MySQL root password.

    This will create a plain text file called yourdbname.sql that contains all of the MySQL statements needed to create the database again in exactly the same state. Copy the file to the "new" server, create the database, and import it:

    Code:
    # mysql
    mysql> create database yourdbname;
    mysql> exit
    # mysql yourdbname < yourdbname.sql
    Note the direction of the greater-than and less-than symbols. Greater-than (>) redirects output to a file, and less-than (<) instructs a command to take its input from a file.

    More about the mysqldump command is available in the MySQL documentation:

    MySQL :: MySQL 5.1 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program
     
  7. lasica

    lasica Registered

    Joined:
    Oct 23, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi, I have a related problem.
    There is a database (let's call it user_db3) that seems to be associated with the account, as I can log in into cPanel (not Web Host Manager, but a 'reseller' level in cPanel) and see it if I use phpMyAdmin or MySqlDatabases. We have a daily/weekly/monthly backup running for all accounts set up through Web Host Manager, and in the created backup there is a folder 'mysql' under that account (owner's) name where I can see SQL files for other databases under the same account, but not this particular user_db3 database. Assuming these SQL files are indeed the database 'backups' (e.g sql commands needed to recreate a aprticular database), I am not sure why is this user_db3 database not been backed up, while the others are.

    I'd like to have this user_db3 database backed up when the WHM scheduled backup runs. What do I need to do?

    Thank you.
     
  8. 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
    Does the database show up in cPanel > MySQL Databases area? If a user added the database via PhpMyAdmin, it will show up in PhpMyAdmin but not in cPanel > MySQL Databases area due to not being properly mapped to cPanel for that user.

    You can check if the database exists for our mapping by grepping for it in the cPanel database mapping directory:

    Code:
    grep user_db3 /var/cpanel/databases/*
     
Loading...

Share This Page