使用pv協助備份資料庫

來源:互聯網
上載者:User

標籤:使用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 目錄下打包檔案名稱為[email protected]

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

 

[[email protected]]# 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.   協助備份資料庫

 

[[email protected]_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.

[[email protected]_tools]# gunzip -fc accounts.gzip |mysql -uroot -p accounts

Enterpassword: 

-- pv在這裡做限流左右


使用pv協助備份資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.