matfish Posted March 6, 2009 Share Posted March 6, 2009 Hi, I'm having a little trouble. I'm moving a 280Mb database to a new server which consists of about 36 tables. As you can imagine phpMyadmin is having trouble with the export and import. I have found command line ways to backup the whole database but I was wondering if there is a way to backup individual tables and then import the individual tables via SSH? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/ Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 mysqldump Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/#findComment-778192 Share on other sites More sharing options...
tomfmason Posted March 6, 2009 Share Posted March 6, 2009 Here is an excerpt from a bash script that I used to use for backing up my entire server backup.sh #!/usr/bin/env bash function backup_sql() { dbs=`mysql -u root --batch -e "SHOW DATABASES;"` backup_dir=/backups/mysql/ for db in $dbs; do if [ "$db" != "Database" ]; then mysqldump --opt -c -e -Q -q --single-transaction -u root $db > $backup_dir/$db.sql fi done } if type "$1" | grep -qF "$1 is a function"; then "$@"; fi Usage: backup.sh backup_sql If you only want to backup one db just do something like this mysqldump --opt -c -e -Q -q --single-transaction -u root YOUR_DB > /path/to/YOUR_DB.sql I now use LVM snapshots for backing up/migrating my mysql server. Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/#findComment-778198 Share on other sites More sharing options...
matfish Posted March 6, 2009 Author Share Posted March 6, 2009 Thats great thank you but I'm trying to backup a specific table out of the database? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/#findComment-778214 Share on other sites More sharing options...
tomfmason Posted March 6, 2009 Share Posted March 6, 2009 Thats great thank you but I'm trying to backup a specific table out of the database? Many thanks Yeah just add the table name after the db. Like this: mysqldump --opt -c -e -Q -q --single-transaction -u root YOUR_DB YOUR_TABLE > /path/to/YOUR_TABLE.sql Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/#findComment-778226 Share on other sites More sharing options...
matfish Posted March 6, 2009 Author Share Posted March 6, 2009 Thats great - thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/148235-solved-command-line-database-table-backup/#findComment-778241 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.