码迷,mamicode.com
首页 > 数据库 > 详细

使用pv协助备份数据库

时间:2014-12-29 15:39:02      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:使用pv协助备份数据库

1.1.   安装和帮助

PV 全命为Pipe Viewer,利用它我们可以查看到命令执行的进度。

# wgethttp://www.ivarch.com/programs/sources/pv-1.5.3.tar.bz2

# tar xjfpv-1.1.4.tar.bz2

# cdpv-1.1.4

#./configure

# make&& make install

 

例:需要将/home/opt 目录下打包文件名称为opt@yy-mm-dd.

# tar -p -cf - /home/opt | pv --size `du -sk /home/opt | cut -f 1`k | gzip>/home/opt@`date +%y-%m-%d`.tar.gz

 

[root@gfsunny105pv-1.5.7]# pv --help

Usage: pv[OPTION] [FILE]...

ConcatenateFILE(s), or standard input, to standard output,

withmonitoring.

 

  -p, --progress           show progress bar

  -t, --timer              show elapsed time

  -e, --eta                show estimated time of arrival(completion)

  -r, --rate               show data transfer rate counter

  -a, --average-rate       show data transfer average rate counter

  -b, --bytes              show number of bytes transferred

  -T, --buffer-percent     show percentage of transfer buffer in use

  -A, --last-written NUM   show NUM bytes last written

  -F, --format FORMAT      set output format to FORMAT

  -n, --numeric            output percentages, not visualinformation

  -q, --quiet              do not output any transferinformation at all

 

  -W, --wait               display nothing until first bytetransferred

  -s, --size SIZE          set estimated data size to SIZE bytes

  -l, --line-mode          count lines instead of bytes

  -0, --null               lines are null-terminated

  -i, --interval SEC       update every SEC seconds

  -w, --width WIDTH        assume terminal is WIDTH characters wide

  -H, --height HEIGHT      assume terminal is HEIGHT rows high

  -N, --name NAME          prefix visual information with NAME

  -f, --force              output even if standard error isnot a terminal

  -c, --cursor             use cursor positioning escapesequences

 

  -L, --rate-limit RATE    limit transfer to RATE bytes per second

  -B, --buffer-size BYTES  use a buffer size of BYTES

  -C, --no-splice          never use splice(), always useread/write

  -E, --skip-errors        skip read errors in input

  -S, --stop-at-size       stop after --size bytes have beentransferred

  -R, --remote PID         update settings of process PID

 

  -P, --pidfile FILE       save process ID in FILE

 

  -d, --watchfd PID[:FD]   watch file FD opened by process PID

 

  -h, --help               show this help and exit

  -V, --version            show version information and exit

1.2.   协助备份数据库

 

[root@gfsunny105mysql_tools]# mysqldump -uroot -p123456 --single-transaction --databases accounts |pv -q -L 10m |gzip>accounts.gzip

Warning:Using a password on the command line interface can be insecure.

[root@gfsunny105mysql_tools]# gunzip -fc accounts.gzip |mysql -uroot -p accounts

Enterpassword: 

-- pv在这里做限流左右


使用pv协助备份数据库

标签:使用pv协助备份数据库

原文地址:http://gfsunny.blog.51cto.com/990565/1597136

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!