2020-09-14

Use-Tar-Backup-Linux

1. Backup System
2. Use Tar Backup Linux System
 2.1 本次备份在LiveCD环境下进行(20200911)
  2.1.1 系统环境状态概述
  2.1.2 tar -cpzvf /media/Sv/bk2020-09.tgz ./
  2.1.3 tar -xpzvf bk2020-09.tgz -C /mnt/sda6
 2.2 本次备份在arch系统环境下进行(20200912)
  2.2.1 系统环境状态概述
  2.2.2 tar cpzf /mnt/Sv/bk0912.tgz --exclude=/dev --exclude=/home --exclude=/lost+found --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/sys --exclude=/tmp /
  2.2.3 tar xpzf bk0912.tgz -C /
 2.3 本次备份在LiveCD环境下进行(20200913)
  2.3.1 系统环境状态概述
  2.3.2 tar -cpzvf /media/Sv/bk0913x-pkg.tgz --exclude=./var/cache/pacman/pkg/* ./
  2.3.3 小结
3. pkglist

1. Backup System

几十年来,Window系统备份一直使用ghost。我不知道有没有其他替代品,但也没想过去找,因为这个ghost就足够好用了。
ghost不支持linux的常见文件系统。Linux系统的备份五花八门有很多种方式。比如使用dd完整备份系统
# dd if=/dev/sda6 | gzip > s6arch2020-08.img.gz
# gzip -dc s6arch2020-08.img.gz | dd of=/dev/sd??...
但存在如下问题。
  • 速度慢,单纯的dd命令若使用bs=1M设定块大小,可以显著提高速度,但若使用gzip压缩,指定多大的块都没用。
  • 若不使用gzip等压缩,就需要原始磁盘大小的空间存放备份文件。
  • 只能还原到原始大小的盘。
Linux系统,一切皆文件,既然是文件,要备份,只需要复制即可。本文记录使用tar备份系统的过程。

2. Use Tar Backup Linux System

2.1 本次备份在LiveCD环境下进行(20200911)

2.1.1 系统环境状态概述

已安装桌面及基本工具chromium (SwitchyOmega) firefox qbittorrent vlc libreoffice ibus等,但xfce4还未清理,安装了全部。详见: Qqlist2020-08v09.xls
$ sudo pacman -Q |wc -l
591
$ sudo pacman -Qe |wc -l
113
$ neofetch
                   -`                    tom@tompc 
                  .o+`                   --------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: F.20 
               `+oooooo:                 Kernel: 5.8.7-arch1-1 
               -+oooooo+:                Uptime: 42 mins 
             `/:-:++oooo+:               Packages: 591 (pacman) 
            `/++++/+++++++:              Shell: bash 5.0.18 
           `/++++++++++++++:             Resolution: 1280x800 
          `/+++ooooooooooooo/`           DE: Xfce 4.14 
         ./ooosssso++osssssso+`          WM: Xfwm4 
        .oossssso-````/ossssss+`         WM Theme: Default 
       -osssssso.      :ssssssso.        Theme: Adwaita [GTK2/3] 
      :osssssss/        osssso+++.       Icons: Adwaita [GTK2/3] 
     /ossssssss/        +ssssooo/-       Terminal: xfce4-terminal 
   `/ossssso+/:-        -:/+osssso+-     Terminal Font: Monospace 12 
  `+sso+:-`                 `.-/+oso:    CPU: Intel Core 2 Duo T8300 (2) @ 2.40 
 `++:.                           `-/+/   GPU: Intel Mobile GM965/GL960 
 .`                                 `/   Memory: 1060MiB / 7950MiB 
 # df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb6        30G  5.4G   24G  19% /media/mint/Sarch

2.1.2 tar -cpzvf /media/Sv/bk2020-09.tgz ./

# cd /media/Sarch
# tar -cpzvf /media/Sv/bk2020-09.tgz ./
$ du -sh bk2020-09.tgz
2.6G bk2020-09.tgz

# md5sum s6arch2020-09.tgz
7111af74b95718d1326dde7bebbfd8be  s6arch2020-09.tgz
# shasum s6arch2020-09.tgz
58656fd0daa2c62978d8f3674c9d70b68a533ba5  s6arch2020-09.tgz

2.1.3 tar -xpzvf bk2020-09.tgz -C /mnt/sda6

# tar -xpzvf bk2020-09.tgz -C /mnt/sda6
(记得检查fstab, grub文件)

2.2 本次备份在arch系统环境下进行(20200912)

2.2.1 系统环境状态概述

在0911基础上,清理了xfce4不必要的桌面项目,
$ sudo pacman -Rsun parole xfburn xfce4-screenshooter orage iwd xfce4-cpufreq-plugin xfce4-mailwatch-plugin xfce4-notes-plugin xfce4-wavelan-plugin xfce4-weather-plugin
 增加了vbox,gimp,等软件包...
$ sudo pacman -S usbutils smartmontools lostfiles dos2unix convmv fzf virtualbox (virtualbox-host-modules-arch) aria2 elinks links privoxy shadowsocks hexchat gimp whois ltrace strace traceroute lsof
 配置了桌面sensors等,但clamav还未更新启用...
$ uname -r
5.8.8-arch1-1

2.2.2 tar cpzf /mnt/Sv/bk0912.tgz --exclude=/dev --exclude=/home --exclude=/lost+found --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/sys --exclude=/tmp /

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        30G  8.7G   20G  31% /

$ sudo tar cpzf /mnt/Sv/bk0912.tgz --exclude=/dev --exclude=/home --exclude=/lost+found --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/sys --exclude=/tmp /
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets
tar: /etc/pacman.d/gnupg/S.gpg-agent.extra: socket ignored
tar: /etc/pacman.d/gnupg/S.gpg-agent.browser: socket ignored
tar: /etc/pacman.d/gnupg/S.gpg-agent.ssh: socket ignored
tar: /etc/pacman.d/gnupg/S.gpg-agent: socket ignored
tar: /: file changed as we read it

$ du -sh bk0912.tgz 
2.8G bk0912.tgz

$ md5sum bk0912.tgz 
081cad8b846334042651fa5708c092f2  bk0912.tgz
$ shasum bk0912.tgz 
9fc5a682a0f87d7ab9f9b9810489e62f2ae68ed2  bk0912.tgz

2.2.3 tar xpzf bk0912.tgz -C /

$ sudo tar xpzf bk0912.tgz -C /
$ mkdir dev home lost+found mnt proc run sys tmp
(记得检查fstab, grub文件)

2.3 本次备份在LiveCD环境下进行(20200913)

2.3.1 系统环境状态概述

在0912基础上,更新clamav; pacman -S gedit;
$ sudo freshclam
$ sudo systemctl enable clamav-freshclam.service
$ sudo systemctl start clamav-freshclam.service
$ sudo systemctl enable clamav-daemon.service
$ sudo systemctl start clamav-daemon.service
$ curl https://secure.eicar.org/eicar.com.txt |clamscan -
输出必须包括:
stdin: Win.Test.EICAR_HDB-1 FOUND

2.3.2 tar -cpzvf /media/Sv/bk0913x-pkg.tgz --exclude=./var/cache/pacman/pkg/* ./

 # cd /media/Sarch/
 # df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb6        30G  6.1G   23G  22% /media/mint/Sarch
 # tar -cpzvf /media/Sv/bk0913x-pkg.tgz --exclude=./var/cache/pacman/pkg/* ./
 ~ <= 8min ~
 # du -sh bk0913x-pkg.tgz 
1.9G bk0913x-pkg.tgz

 # md5sum bk0913x-pkg.tgz 
63598a394f2c0b3ce5f67e7e00b1b805  bk0913x-pkg.tgz
 # shasum bk0913x-pkg.tgz 
f00fa8a751967f26b401ca208661d732f47ffeee  bk0913x-pkg.tgz

2.3.3 小结

备份使用2.3.2,排除pkg包可以显著减少备份体积。
6.1G的桌面系统排除1.1G的pkg包,还有5G大小。压缩打包1.9Gb, 用时8分钟。

通常,普通用户环境备份的内容就下面这5个文件夹
  • /usr 4.4Gb 142948 items
  • /var 1.4Gb 3496 items (/var/cache/pacman/pkg 1.1Gb 627 items)
  • /boot 74.1Mb 381 items
  • /root 53.3Mb 745 items
  • /etc 4.9Mb 1451 items
连接目录:
  • bin -> usr/bin
  • lib -> usr/lib
  • lib64 -> usr/lib
  • sbin -> usr/bin
系统运行过程目录,不需要备份
rwxr-xr-x 5 4096 mnt
rwxr-xr-x 20 3620 dev
rwxr-xr-x 20 500 run
r-xr-xr-x 13 0 sys
r-xr-xr-x 222 0 proc
rwxrwxrwt 10 260 tmp
rwx------ 2 16384 lost+found

其他目录,普通用户很少会用到
rwxr-xr-x 2 4096 opt
rwxr-xr-x 4 4096 srv

3. pkglist

$ pacman -Qq |wc -l
626

$ pacman -Qqe |wc -l
122
xfce4-appfinderflameshotcatfishnetwork-manager-applet
xfce4-artworkgimpxarchivernetworkmanager
xfce4-battery-plugingeditunrarnetctl
xfce4-clipman-pluginviunzipdhclient
xfce4-cpugraph-pluginmeldzipdialog
xfce4-datetime-pluginhardinfop7zipiw
xfce4-dicthtopnethogsthunar
xfce4-diskperf-pluginneofetchiftopthunar-archive-plugin
xfce4-eyes-pluginfdlinksthunar-media-tags-plugin
xfce4-fsguard-pluginmlocateelinksthunar-volman
xfce4-genmon-pluginconvmvchromiumxf86-input-libinput
xfce4-mount-plugindos2unixfirefoxxf86-video-intel
xfce4-mpc-pluginexov2rayxfconf
xfce4-netload-pluginalsa-utilsshadowsocksxfdesktop
xfce4-notifydpulseaudioprivoxyxfwm4
xfce4-panelbaobabaria2xfwm4-themes
xfce4-power-managerntfs-3gqbittorrentxorg-server
xfce4-pulseaudio-pluginvlcclamavxorg-xinit
xfce4-screensaverristrettorkhunteradobe-source-han-sans-cn-fonts
xfce4-sensors-pluginman-dbwhoisibus
xfce4-sessiontreehexchatibus-libpinyin
xfce4-settingssudotracerouteintel-ucode
xfce4-smartbookmark-pluginbasersynclibreoffice-fresh
xfce4-systemload-plugingarconpacman-contriblibreoffice-fresh-zh-cn
xfce4-taskmanagergvfspacutilslightdm
xfce4-terminallsofpkgstatslightdm-gtk-greeter
xfce4-time-out-pluginltracefzfvirtualbox
xfce4-timer-pluginstracelostfileslinux
xfce4-verve-plugintumblermesa-demoslinux-firmware
xfce4-whiskermenu-pluginusbutilssmartmontoolsgrub
xfce4-xkb-plugin

os-prober
$ pacman -Qqd |wc -l
504
pythongnupgpinentryxorg-fonts-encodingslibnsl
python-appdirsgnutlspixmanxorg-iceauthlibnumbertext
python-cairogobject-introspection-runtimepolkitxorg-server-commonlibodfgen
python-dbusgpgmepolkit-gnomexorg-setxkbmaplibogg
python-dbus-commongpmpopplerxorg-xauthlibomxil-bellagio
python-gobjectgptfdiskpoppler-dataxorg-xkbcompliborcus
python-ordered-setgraphitepoppler-glibxorg-xmodmaplibp11-kit
python-packaginggreppoptxorg-xproplibpagemaker
python-pexpectgroffprocps-ngxorg-xrdblibpcap
python-ptyprocessgsettings-desktop-schemaspsmiscxorg-xsetlibpciaccess
python-pyparsinggsfontspygobject-develxorgprotolibpeas
python-pyxdggsmqrencodelibabwlibpgm
python-setuptoolsgspellqt5-baselibaiolibpinyin
python-sixgtk-update-icon-cacheqt5-svglibappindicator-gtk3libpipeline
python2gtk2qt5-x11extraslibarchivelibplacebo
python2-dbusgtk3raptorlibasslibplist
python2-gobjectgtksourceview3rasqallibassuanlibpng
python2-gobject2gtksourceview4rav1elibasyncnslibproxy
a52decgzipre2libatasmartlibpsl
aclharfbuzzreadlinelibatomic_opslibpulse
adobe-source-code-pro-fontsharfbuzz-icuredlandlibavc1394libqxp
adwaita-icon-themehicolor-icon-themerestlibblockdevlibraw
alsa-libhidapirtkitlibbluraylibraw1394
alsa-topology-confhunspellrun-partslibbytesizelibrevenge
alsa-ucm-confhwidssdllibcanberralibrsvg
amtkhyphensdl2libcaplibsamplerate
aomiana-etcsedlibcap-nglibsasl
archlinux-keyringicushaderclibcddblibseccomp
argon2inetutilsshadowlibcdiolibsecret
aribb24iproute2shared-mime-infolibcdio-paranoialibsm
at-spi2-atkiptablesslanglibcdrlibsndfile
at-spi2-coreiputilssnappylibcmislibsodium
atkiso-codessound-theme-freedesktoplibcrocolibsoup
attrjackspeexlibcupslibsoxr
auditjanssonspeexdsplibdaemonlibspiro
avahijasperspirv-toolslibdatrielibssh
babljs68sqlitelibdbusmenu-gliblibssh2
bashjson-csrtlibdbusmenu-gtk3libstaroffice
blasjson-glibstartup-notificationlibdcalibtar
bluez-libskbdsuitesparselibde265libtasn1
boost-libskeyutilssysfsutilslibdrmlibteam
brotlikmodsystemdlibdvbpsilibthai
btrfs-progskrb5systemd-libslibe-booklibtheora
bzip2kyotocabinetsystemd-sysvcompatlibebmllibtiff
c-aresl-smashtagliblibeditlibtirpc
ca-certificateslametarlibelflibtommath
ca-certificates-mozillalapacktbblibepoxylibtool
ca-certificates-utilslcms2tdblibepubgenlibtorrent-rasterbar
cairolensfuntepllibetonyeklibunistring
cantarell-fontslessthin-provisioning-toolslibevdevlibunwind
clucenelicensestrelibeventlibupnp
colordlinux-api-headerstsliblibexiflibusb
coreutilsllvm-libsttf-liberationlibexttextcatlibusbmuxd
cryptsetuplm_sensorstzdatalibffilibva
curllpsolveuchardetlibfontenclibvdpau
dav1dlua51udisks2libfreehandlibvisio
dblua52upowerlibgcryptlibvorbis
dbuslua53usbmuxdlibgexiv2libvpx
dbus-glibluajitutil-linuxlibglvndlibwacom
dconflvm2util-linux-libslibgpg-errorlibwebp
desktop-file-utilslz4v2ray-domain-list-communitylibgudevlibwmf
device-mapperlzov2ray-geoiplibgusblibwnck3
diffutilsmailcapv4l-utilslibheiflibwpd
dmraidmd4cvid.stablibibuslibwpg
dosfstoolsmdadmvirtualbox-host-modules-archlibicelibwps
double-conversionmesavmaflibidnlibx11
e2fsprogsmetisvolume_keylibidn2libxau
elfutilsminizipvte-commonlibiec61883libxcb
enchantmkinitcpiovte3libimobiledevicelibxcomposite
exiv2mkinitcpio-busyboxvulkan-icd-loaderlibindicator-gtk3libxcrypt
expatmobile-broadband-provider-infowaylandlibinputlibxcursor
faad2mpfrwayland-protocolslibixionlibxdamage
fakerootmtdevwebrtc-audio-processinglibjpeg-turbolibxdmcp
ffmpegmypaint-brushes1wgetlibkeybinder3libxext
filencurseswhichlibksbalibxfce4ui
filesystemndctlwpa_supplicantliblangtaglibxfce4util
findutilsneonx264libldaplibxfixes
flacnettlex265libmadlibxfont2
fontconfignm-connection-editorxcb-protolibmatroskalibxft
freeglutnpthxcb-utillibmfxlibxi
freetype2nsprxcb-util-imagelibmicrohttpdlibxinerama
fribidinssxcb-util-keysymslibmm-gliblibxkbcommon
fuse-commonopenccxcb-util-renderutillibmnglibxkbcommon-x11
fuse2opencore-amrxcb-util-wmlibmnllibxkbfile
fuse3openexrxdg-utilslibmodpluglibxklavier
gawkopenjpeg2xfsprogslibmpcdeclibxml2
gcopenresolvxkeyboard-configlibmpdlibxmu
gcc-libsopensslxmlseclibmpeg2libxpm
gcropusxvidcorelibmspacklibxpresent
gdbmorcxxhashlibmspublibxrandr
gdk-pixbuf2p11-kitxzlibmwawlibxrender
geglpacmanzeromqlibmypaintlibxres
gettextpacman-mirrorlistzita-alsa-pcmilibndplibxshmfence
giflibpamzita-resamplerlibnetfilter_conntracklibxslt
glewpambasezliblibnewtlibxss
glib-networkingpangozstdlibnfnetlinklibxt
glib2parted
libnftnllibxtst
glibcpciutils
libnghttp2libxv
glslangpcre
libnllibxvmc
glupcre2
libnmlibxxf86vm
gmpperl
libnmalibyaml
gnome-themes-extraperl-uri
libnotifylibzmf

Diode

导航 (返回顶部) 1. Diode 1.1 Diode 概述 1.2 肖克利二极管方程 1.3 缩写 Abbreviations 2. 主要功能 2.1 单向电流 (Unidirectional current flow) 2.2 阈值电压 (Threshold...