生产环境中常常将数据库备份至远程服务器,本次测试中,数据库服务器:192.168.8.50,远程备份中心:192.168.8.63
1、配置SSH秘钥认证
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub mysql@192.168.8.63
2、使用tar进行备份并以时间对备份进行命名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /usr/local/xtrabackup/bin/innobackupex --defaults- file = /etc/my .cnf --user=root --password=mysql --port 3306 --socket= /tmp/mysqld .sock --stream= tar ./ | ssh mysql@192.168.8.63 \ "cat - > /backup_center/$(date +%Y-%m-%d_%H:%m:%S).tar" 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/user_bak .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/time_zone .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/help_relation .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/time_zone_transition_type .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/help_topic .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/db .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/slow_log .CSM to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/slow_log .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/general_log .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/slave_relay_log_info .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/tables_priv .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/ndb_binlog_index .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/slave_master_info .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/func .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/proc .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/time_zone_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/func .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/procs_priv .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/tables_priv .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/columns_priv .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/general_log .CSM to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/ndb_binlog_index .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/gtid_executed .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/procs_priv .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/func .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/help_keyword .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/columns_priv .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/proxies_priv .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/proc .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/time_zone_transition .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/time_zone_leap_second .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/general_log .CSV to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/servers .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/help_category .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/proxies_priv .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/event .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/engine_cost .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/user .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/ndb_binlog_index .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/db .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/plugin .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/user .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/columns_priv .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/innodb_table_stats .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/innodb_index_stats .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/event .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/slow_log .CSV to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/db .MYI to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /mysql/user .MYD to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_history .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_history .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_digest .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/hosts .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/prepared_statements_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/rwlock_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/threads .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/setup_objects .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/objects_summary_global_by_type .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_connection_status .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_thread_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/memory_summary_by_host_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_host_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/session_variables .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_group_member_stats .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/setup_actors .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/memory_summary_by_account_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_history_long .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/users .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/setup_consumers .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_history_long .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_global_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_program .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/file_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/table_handles .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/variables_by_thread .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/memory_summary_global_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_summary_by_user_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/table_io_waits_summary_by_index_usage .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_summary_global_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/status_by_host .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_by_thread_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_summary_by_account_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/session_connect_attrs .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/status_by_account .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/metadata_locks .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_summary_by_host_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_history_long .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/global_variables .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/table_lock_waits_summary_by_table .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/mutex_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/session_status .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_summary_by_account_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_summary_by_user_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/table_io_waits_summary_by_table .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_current .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_current .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_connection_configuration .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/memory_summary_by_thread_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/status_by_thread .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_applier_status_by_worker .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/cond_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/performance_timers .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_global_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/accounts .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/session_account_connect_attrs .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_by_instance .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/setup_instruments .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_by_user_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_current .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_summary_by_thread_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_history_long .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/global_status .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_group_members .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_summary_by_host_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_applier_status_by_coordinator .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/file_summary_by_instance .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_current .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/socket_summary_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/db .opt to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/socket_instances .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_summary_global_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/setup_timers .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/host_cache .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_by_account_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_history .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_transactions_summary_by_thread_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/user_variables_by_thread .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/file_summary_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_user_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_stages_history .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_applier_status .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_statements_summary_by_account_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/socket_summary_by_instance .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/status_by_user .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/memory_summary_by_user_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/events_waits_summary_by_host_by_event_name .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 [01] Streaming . /performance_schema/replication_applier_configuration .frm to <STDOUT> 180809 16:23:53 [01] ... done 180809 16:23:53 Finished backing up non-InnoDB tables and files 180809 16:23:53 [00] Streaming <STDOUT> 180809 16:23:53 [00] ... done 180809 16:23:53 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point ( for incremental): '3504097424' xtrabackup: Stopping log copying thread. .180809 16:23:53 >> log scanned up to (3504097433) 180809 16:23:53 Executing UNLOCK TABLES 180809 16:23:53 All tables unlocked 180809 16:23:53 [00] Streaming ib_buffer_pool to <STDOUT> 180809 16:23:53 [00] ... done 180809 16:23:53 Backup created in directory '/backup/full_backup/' MySQL binlog position: filename 'mysql-bin.000013' , position '154' 180809 16:23:53 [00] Streaming <STDOUT> 180809 16:23:53 [00] ... done 180809 16:23:53 [00] Streaming <STDOUT> 180809 16:23:53 [00] ... done xtrabackup: Transaction log of lsn (3504097424) to (3504097433) was copied. 180809 16:23:53 completed OK! |
3、登录备份服务器查看备份文件
1 2 3 | [root@oneproxy backup_center] # ll total 3683656 -rw-rw-r-- 1 mysql mysql 3772058112 Aug 9 16:24 2018-08-09_16:08:13. tar |