Topic: Backup function code analysis
The Wiki has this post's contents.
Backup Code Analysis
- The key file where the backup originates is admin/db/maintenance_db.inc 
- In it, the key function that starts the backup is function db_backup() - Parameter $tbpref makes it generic enabling usage of other prefixes possibly within extensions or in customisations 
- Creates the name of the backup sql file and goes to function db_export() 
 
- The actual backing up is done in the function db_export() - Parameter $tbpref makes it generic enabling usage of other prefixes possibly within extensions or in customisations 
- If no prefix is there for a company and other companies data resides in the same db, then all tables in the db including those of other companies in it too will get backed up! 
- Sets max chunk size before writing to sql backup file to 2MB or if present, from memory_limit value in php.ini 
- Writes standard parameters to sql backup as comments 
- Writes user comments to sql backup as comments 
- Acquire all table names in db and shortlist them based on prefix or all on no prefix! 
- SQL comment character hardcoded as "#" throughout 
 
If your backup is taking too long, then tune the MySQL server with mysqltuner. In debian, install with apt-get install mysqltuner. Usage:
mysqlcheck -o mydbname
mysqltunerand monitor with:
tail -fn0 /var/log/mysql.err
tail -n15 /var/log/mysql.err
vmstat 5 5
