linux:backup

  • login to root with ssh key

#/etc/ssh/sshd_config

PermitRootLogin without-password
PubkeyAuthentication yes
service sshd restart
ls /usr/bin/*session
dpkg -l|egrep -i "(kde|gnome|lxde|xfce|mint|unity|fluxbox|openbox)" | grep -v library
apt-cache -o APT::Cache::GivenOnly=1 dotty gnome-system-tools | dot -T png > out.png
apt-cache rdepends  --installed libx11-6
  • wajig

sudo apt-get install wajig

wajig large
  • Show Installed Package Size using dpkg-query

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10

awk 'BEGIN{

  FS=" - ";
  findmeta="apt-cache search . | grep -i \"metapackage\\|meta-package\"";
  while ((findmeta | getline) > 0)  meta[$1]=$2;
  FS=" ";
  findinstalled="dpkg --get-selections";
  while ((findinstalled | getline) > 0) {
      if ($1 in meta) print $1" - "meta[$1]
  }

}'

sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 \
  "DELETE FROM bans WHERE DATE(timeofban, 'unixepoch') < '2021-08-19'; VACUUM;"
  • gzip - fast
  • tar gz → root /

tar -czvf - –one-file-system –ignore-failed-read –exclude=/backup.tar.gz –exclude=/proc –exclude=/tmp –exclude=/mnt –exclude=/dev –exclude=/sys –exclude=/run –exclude=/media –exclude=/var/log –exclude=/var/cache/apt/archives –exclude=/var/lib/lxcfs / | pv | cat > /tmp/bot-ar-`date +%m-%d-%Y`.tgz

  • tar gz → /boot

tar -czvf - –one-file-system –ignore-failed-read /boot | pv | cat > /tmp/bot-ar-boot-`date +%m-%d-%Y`.tgz

  • only if root available for login SSH
  ssh root@bot.ip2u.ru 'cd / && tar -cvf - --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/log --exclude=/var/lib/lxcfs/ --exclude=/var/cache/apt/archives  / | gzip -9 ' |  pv | cat > /mnt/d/backup/bot-ar/bot-ar-`date +%m-%d-%Y`.tgz
 
  • brotli - very slow

tar -cf - –exclude=/backup.tar.gz –exclude=/proc –exclude=/tmp –exclude=/mnt –exclude=/dev –exclude=/sys –exclude=/run –exclude=/media –exclude=/var/log –exclude=/var/cache/apt/archives / | brotli | pv | cat > /tmp/bot-ar-`date +%m-%d-%Y`.tar.bt

* local run save to ssh
   tar -cvf - --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/log --exclude=/var/lib/lxcfs/ --exclude=/var/cache/apt/archives / | gzip -9 | ssh user@remote_server.example.com 'cat > /path/to/backup/bot-ar-`date +%m-%d-%Y`.tgz'
  • linux/backup.txt
  • Last modified: 2024/06/03 13:48
  • by admin