mysqlhotcopy

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

mysqlhotcopy è uno script Perl scritto originariamente da Tim Bunce. Utilizza i comandi FLUSH TABLES, LOCK TABLES e cp o scp per creare il backup di un database. E' un modo veloce per ottenere il backup di un database o di singole tabelle, ma deve essere eseguito sulla stessa macchina in cui si trovano le directory dei database. mysqlhotcopy funziona solo su tabelle MyISAM e ARCHIVE. Funziona su Unix e NetWare.

Per usare mysqlhotcopy occorre avere accesso ai file che compongono le tabelle che si desidera copiare, il privilegio SELECT sulle stesse tabelle, il privilegio RELOAD (per poter eseguire FLUSH TABLES) e il privilegio LOCK TABLES (per poter porre un lock sulle tabelle).

shell> mysqlhotcopy nome_db [/percorso/della/nuova/directory]
shell> mysqlhotcopy nome_db_1 ... db_name_n /percorso/della/nuova/directory

Per fare il backup delle tabelle, all'interno di un database, che corrispondono a una certa espressione regolare:

shell> mysqlhotcopy nome_db./regex/

L'espressione regolare può essere invertito aggiungendo una tilde (“~”):

shell> mysqlhotcopy nome_db./~regex/

mysqlhotcopy supporta le opzioni seguenti, che possono essere specificate dalla riga di comando o nei file di configurazione, nei gruppi [mysqlhotcopy] e [client].

  • --help, -?
    • Mostra un messaggio di help e termina.
  • --addtodest
    • Non rinomina la directory di destinazione (se esiste): vi aggiunge i file.
  • --allowold
    • Non abortisce se la directory di destinazione esiste; la rinomina aggiungendo il suffisso _old.
  • --checkpoint=nome_db.nome_tab
    • Inserisce dei checkpoint nel database specificato nome_db e nella tabella nome_tab.
  • --chroot=percorso
    • Directory base della cella chroot nella quale opera mysqld. Il valore del percorso dovrebbe corrispondere a quello dell'opzione --chroot passata a mysqld.
  • --debug
    • Abilita il debug.
  • --dryrun, -n
    • Stampa le azioni che sta eseguendo.
  • --flushlog
    • Svuota i log dopo aver posto un lock su tutte le tabelle.
  • --host=nome_host, -h nome_host
    • Il nome host dell'host locale per effettuare una connessione TCP/IP al server locale. Per default, la connessione è verso localhost e usa un file di socket Unix.
  • --keepold
    • Non cancella la destinazione precedente (rinominata) quando ha finito.
  • --method=comando
    • Il metodo per copiare i file (cp o scp). Quello predefinito è cp.
  • --noindices
    • Do not include full index files for MyISAM tables in the backup. This makes the backup smaller and faster. The indexes for reloaded tables can be reconstructed later with myisamchk -rq.
  • --password=password, -ppassword
    • The password to use when connecting to the server. The password value is not optional for this option, unlike for other MySQL programs.

      Specifying a password on the command line should be considered insecure. You can use an option file to avoid giving the password on the command line.
  • --port=port_num, -P port_num
    • The TCP/IP port number to use when connecting to the local server.
  • --quiet, -q
    • Be silent except for errors.
  • --record_log_pos=db_name.tbl_name
    • Record master and slave status in the specified database db_name and table tbl_name.
  • --regexp=expr
    • Copy all databases with names that match the given regular expression.
  • --resetmaster
    • Reset the binary log after locking all the tables.
  • --resetslave
    • Reset the master.info file after locking all the tables.
  • --socket=path, -S path
    • The Unix socket file to use for connections to localhost.
  • --suffix=str
    • The suffix to use for names of copied databases.
  • --tmpdir=path
    • The temporary directory. The default is /tmp.
  • --user=user_name, -u user_name
    • The MySQL user name to use when connecting to the server.

Use perldoc for additional mysqlhotcopy documentation, including information about the structure of the tables needed for the --checkpoint and --record_log_pos options:

shell> perldoc mysqlhotcopy

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.