linux:backup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:backup [2021/08/21 18:43] – created adminlinux:backup [2024/06/03 13:48] (current) – [full local backup to tmp] admin
Line 2: Line 2:
  
   * [[https://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/|howto-use-tar-command-through-network-over ssh session ]]   * [[https://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/|howto-use-tar-command-through-network-over ssh session ]]
 +  * AI ''what is best way to backup dokuwiki on docker and save 2 last copies on google disk.  if possible need to use only bash script''
  
-SSH +===== Backup ===== 
 +==== SSH ====
  
-## login to root with ssh key+  * login to root with ssh key
   #/etc/ssh/sshd_config   #/etc/ssh/sshd_config
   PermitRootLogin without-password   PermitRootLogin without-password
Line 12: Line 14:
  
  
-## check session ( specially for )+==== check session (specially for X====
   ls /usr/bin/*session   ls /usr/bin/*session
  
  
-## check x application+==== check x application ====
   dpkg -l|egrep -i "(kde|gnome|lxde|xfce|mint|unity|fluxbox|openbox)" | grep -v library   dpkg -l|egrep -i "(kde|gnome|lxde|xfce|mint|unity|fluxbox|openbox)" | grep -v library
  
  
-## packages depends+==== packages depends ====
   apt-cache -o APT::Cache::GivenOnly=1 dotty gnome-system-tools | dot -T png > out.png   apt-cache -o APT::Cache::GivenOnly=1 dotty gnome-system-tools | dot -T png > out.png
  
-## find GUI applications +==== find GUI applications  ====
   apt-cache rdepends  --installed libx11-6   apt-cache rdepends  --installed libx11-6
  
-## get large packages +==== get large packages ==== 
-#wajig+  wajig
   sudo apt-get install wajig   sudo apt-get install wajig
   wajig large   wajig large
  
-#Show Installed Package Size using dpkg-query+  * Show Installed Package Size using dpkg-query
   dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10   dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10
  
  
  
-## get installed meta package ( to clear gui)+==== get installed meta package ( to clear gui) ====
 awk 'BEGIN{ awk 'BEGIN{
     FS=" - ";     FS=" - ";
Line 49: Line 51:
 }' }'
  
-## clear fail2ban sqlite base+==== clear fail2ban sqlite base ====
   sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 \   sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 \
     "DELETE FROM bans WHERE DATE(timeofban, 'unixepoch') < '2021-08-19'; VACUUM;"     "DELETE FROM bans WHERE DATE(timeofban, 'unixepoch') < '2021-08-19'; VACUUM;"
  
  
-## full local backup to tmp+==== full local backup to tmp ====
  
-#brotli - slow +  * gzip - fast 
-  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 +  tar gz -> root /
- +
-#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 -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 gz -> /boot+
   tar -czvf - --one-file-system --ignore-failed-read   /boot |   pv | cat > /tmp/bot-ar-boot-`date +%m-%d-%Y`.tgz   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+  * only if root available for login SSH 
 +<code BASH>
   ssh [email protected] '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   ssh [email protected] '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
 +  </code>
  
  
  
 +  * 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
 +<code BASH>
 +   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'
 +</code>
  • linux/backup.1629571426.txt.gz
  • Last modified: 2021/08/21 18:43
  • by admin