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等压缩,就需要原始磁盘大小的空间存放备份文件。
- 只能还原到原始大小的盘。
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 -l626
$ pacman -Qqe |wc -l
122
xfce4-appfinder | flameshot | catfish | network-manager-applet |
xfce4-artwork | gimp | xarchiver | networkmanager |
xfce4-battery-plugin | gedit | unrar | netctl |
xfce4-clipman-plugin | vi | unzip | dhclient |
xfce4-cpugraph-plugin | meld | zip | dialog |
xfce4-datetime-plugin | hardinfo | p7zip | iw |
xfce4-dict | htop | nethogs | thunar |
xfce4-diskperf-plugin | neofetch | iftop | thunar-archive-plugin |
xfce4-eyes-plugin | fd | links | thunar-media-tags-plugin |
xfce4-fsguard-plugin | mlocate | elinks | thunar-volman |
xfce4-genmon-plugin | convmv | chromium | xf86-input-libinput |
xfce4-mount-plugin | dos2unix | firefox | xf86-video-intel |
xfce4-mpc-plugin | exo | v2ray | xfconf |
xfce4-netload-plugin | alsa-utils | shadowsocks | xfdesktop |
xfce4-notifyd | pulseaudio | privoxy | xfwm4 |
xfce4-panel | baobab | aria2 | xfwm4-themes |
xfce4-power-manager | ntfs-3g | qbittorrent | xorg-server |
xfce4-pulseaudio-plugin | vlc | clamav | xorg-xinit |
xfce4-screensaver | ristretto | rkhunter | adobe-source-han-sans-cn-fonts |
xfce4-sensors-plugin | man-db | whois | ibus |
xfce4-session | tree | hexchat | ibus-libpinyin |
xfce4-settings | sudo | traceroute | intel-ucode |
xfce4-smartbookmark-plugin | base | rsync | libreoffice-fresh |
xfce4-systemload-plugin | garcon | pacman-contrib | libreoffice-fresh-zh-cn |
xfce4-taskmanager | gvfs | pacutils | lightdm |
xfce4-terminal | lsof | pkgstats | lightdm-gtk-greeter |
xfce4-time-out-plugin | ltrace | fzf | virtualbox |
xfce4-timer-plugin | strace | lostfiles | linux |
xfce4-verve-plugin | tumbler | mesa-demos | linux-firmware |
xfce4-whiskermenu-plugin | usbutils | smartmontools | grub |
xfce4-xkb-plugin | os-prober |
504
python | gnupg | pinentry | xorg-fonts-encodings | libnsl |
python-appdirs | gnutls | pixman | xorg-iceauth | libnumbertext |
python-cairo | gobject-introspection-runtime | polkit | xorg-server-common | libodfgen |
python-dbus | gpgme | polkit-gnome | xorg-setxkbmap | libogg |
python-dbus-common | gpm | poppler | xorg-xauth | libomxil-bellagio |
python-gobject | gptfdisk | poppler-data | xorg-xkbcomp | liborcus |
python-ordered-set | graphite | poppler-glib | xorg-xmodmap | libp11-kit |
python-packaging | grep | popt | xorg-xprop | libpagemaker |
python-pexpect | groff | procps-ng | xorg-xrdb | libpcap |
python-ptyprocess | gsettings-desktop-schemas | psmisc | xorg-xset | libpciaccess |
python-pyparsing | gsfonts | pygobject-devel | xorgproto | libpeas |
python-pyxdg | gsm | qrencode | libabw | libpgm |
python-setuptools | gspell | qt5-base | libaio | libpinyin |
python-six | gtk-update-icon-cache | qt5-svg | libappindicator-gtk3 | libpipeline |
python2 | gtk2 | qt5-x11extras | libarchive | libplacebo |
python2-dbus | gtk3 | raptor | libass | libplist |
python2-gobject | gtksourceview3 | rasqal | libassuan | libpng |
python2-gobject2 | gtksourceview4 | rav1e | libasyncns | libproxy |
a52dec | gzip | re2 | libatasmart | libpsl |
acl | harfbuzz | readline | libatomic_ops | libpulse |
adobe-source-code-pro-fonts | harfbuzz-icu | redland | libavc1394 | libqxp |
adwaita-icon-theme | hicolor-icon-theme | rest | libblockdev | libraw |
alsa-lib | hidapi | rtkit | libbluray | libraw1394 |
alsa-topology-conf | hunspell | run-parts | libbytesize | librevenge |
alsa-ucm-conf | hwids | sdl | libcanberra | librsvg |
amtk | hyphen | sdl2 | libcap | libsamplerate |
aom | iana-etc | sed | libcap-ng | libsasl |
archlinux-keyring | icu | shaderc | libcddb | libseccomp |
argon2 | inetutils | shadow | libcdio | libsecret |
aribb24 | iproute2 | shared-mime-info | libcdio-paranoia | libsm |
at-spi2-atk | iptables | slang | libcdr | libsndfile |
at-spi2-core | iputils | snappy | libcmis | libsodium |
atk | iso-codes | sound-theme-freedesktop | libcroco | libsoup |
attr | jack | speex | libcups | libsoxr |
audit | jansson | speexdsp | libdaemon | libspiro |
avahi | jasper | spirv-tools | libdatrie | libssh |
babl | js68 | sqlite | libdbusmenu-glib | libssh2 |
bash | json-c | srt | libdbusmenu-gtk3 | libstaroffice |
blas | json-glib | startup-notification | libdca | libtar |
bluez-libs | kbd | suitesparse | libde265 | libtasn1 |
boost-libs | keyutils | sysfsutils | libdrm | libteam |
brotli | kmod | systemd | libdvbpsi | libthai |
btrfs-progs | krb5 | systemd-libs | libe-book | libtheora |
bzip2 | kyotocabinet | systemd-sysvcompat | libebml | libtiff |
c-ares | l-smash | taglib | libedit | libtirpc |
ca-certificates | lame | tar | libelf | libtommath |
ca-certificates-mozilla | lapack | tbb | libepoxy | libtool |
ca-certificates-utils | lcms2 | tdb | libepubgen | libtorrent-rasterbar |
cairo | lensfun | tepl | libetonyek | libunistring |
cantarell-fonts | less | thin-provisioning-tools | libevdev | libunwind |
clucene | licenses | tre | libevent | libupnp |
colord | linux-api-headers | tslib | libexif | libusb |
coreutils | llvm-libs | ttf-liberation | libexttextcat | libusbmuxd |
cryptsetup | lm_sensors | tzdata | libffi | libva |
curl | lpsolve | uchardet | libfontenc | libvdpau |
dav1d | lua51 | udisks2 | libfreehand | libvisio |
db | lua52 | upower | libgcrypt | libvorbis |
dbus | lua53 | usbmuxd | libgexiv2 | libvpx |
dbus-glib | luajit | util-linux | libglvnd | libwacom |
dconf | lvm2 | util-linux-libs | libgpg-error | libwebp |
desktop-file-utils | lz4 | v2ray-domain-list-community | libgudev | libwmf |
device-mapper | lzo | v2ray-geoip | libgusb | libwnck3 |
diffutils | mailcap | v4l-utils | libheif | libwpd |
dmraid | md4c | vid.stab | libibus | libwpg |
dosfstools | mdadm | virtualbox-host-modules-arch | libice | libwps |
double-conversion | mesa | vmaf | libidn | libx11 |
e2fsprogs | metis | volume_key | libidn2 | libxau |
elfutils | minizip | vte-common | libiec61883 | libxcb |
enchant | mkinitcpio | vte3 | libimobiledevice | libxcomposite |
exiv2 | mkinitcpio-busybox | vulkan-icd-loader | libindicator-gtk3 | libxcrypt |
expat | mobile-broadband-provider-info | wayland | libinput | libxcursor |
faad2 | mpfr | wayland-protocols | libixion | libxdamage |
fakeroot | mtdev | webrtc-audio-processing | libjpeg-turbo | libxdmcp |
ffmpeg | mypaint-brushes1 | wget | libkeybinder3 | libxext |
file | ncurses | which | libksba | libxfce4ui |
filesystem | ndctl | wpa_supplicant | liblangtag | libxfce4util |
findutils | neon | x264 | libldap | libxfixes |
flac | nettle | x265 | libmad | libxfont2 |
fontconfig | nm-connection-editor | xcb-proto | libmatroska | libxft |
freeglut | npth | xcb-util | libmfx | libxi |
freetype2 | nspr | xcb-util-image | libmicrohttpd | libxinerama |
fribidi | nss | xcb-util-keysyms | libmm-glib | libxkbcommon |
fuse-common | opencc | xcb-util-renderutil | libmng | libxkbcommon-x11 |
fuse2 | opencore-amr | xcb-util-wm | libmnl | libxkbfile |
fuse3 | openexr | xdg-utils | libmodplug | libxklavier |
gawk | openjpeg2 | xfsprogs | libmpcdec | libxml2 |
gc | openresolv | xkeyboard-config | libmpd | libxmu |
gcc-libs | openssl | xmlsec | libmpeg2 | libxpm |
gcr | opus | xvidcore | libmspack | libxpresent |
gdbm | orc | xxhash | libmspub | libxrandr |
gdk-pixbuf2 | p11-kit | xz | libmwaw | libxrender |
gegl | pacman | zeromq | libmypaint | libxres |
gettext | pacman-mirrorlist | zita-alsa-pcmi | libndp | libxshmfence |
giflib | pam | zita-resampler | libnetfilter_conntrack | libxslt |
glew | pambase | zlib | libnewt | libxss |
glib-networking | pango | zstd | libnfnetlink | libxt |
glib2 | parted | libnftnl | libxtst | |
glibc | pciutils | libnghttp2 | libxv | |
glslang | pcre | libnl | libxvmc | |
glu | pcre2 | libnm | libxxf86vm | |
gmp | perl | libnma | libyaml | |
gnome-themes-extra | perl-uri | libnotify | libzmf |