Monthly Archives: December 2013

Find and replace text in multiple files using geany

To open all files, in which a specific string is found, from inside of a directory (and subdirectories) open Geany, select Terminal tab from Message Window and run next command inside:

grep -rHIF --exclude='/home/modinfo/bitcoin/*~' -- 'text_to_find' /bin/bash /home/modinfo/bitcoin/* | geany `awk 'BEGIN {FS="[:]"} {print $1}'`

source

Quick server backup

mount /dev/xxxx -o remount-ro /mnt
tar -cvjpf serverbackup.tar.bz2 /mnt

then unpack the behavior of permissions

tar -xvjpf serverbackup.tar.bz2

here my script with mysql backup. backup.sh

  1. # create backup catalog
  2. mkdir /backup
  3. # clean
  4. aptitude clean
  5. rm /var/log/*.gz
  6. rm /var/log/apache2/*.gz
  7. rm /var/log/apt/*.gz
  8. rm /var/log/clamav/*.gz
  9. rm /var/backups/*.gz
  10. # start archive
  11. tar -cvjpf /backup/backup_bin.tar.bz2 /bin
  12. tar -cvjpf /backup/backup_home.tar.bz2 /home
  13. tar -cvjpf /backup/backup_lib.tar.bz2 /lib
  14. tar -cvjpf /backup/backup_root.tar.bz2 /root
  15. tar -cvjpf /backup/backup_usr.tar.bz2 /usr
  16. tar -cvjpf /backup/backup_etc.tar.bz2 /etc
  17. tar -cvjpf /backup/backup_lib64.tar.bz2 /lib64
  18. tar -cvjpf /backup/backup_sbin.tar.bz2 /sbin
  19. tar -cvjpf /backup/backup_var.tar.bz2 /var
  20. # backup mysql
  21. mysqldump -u root -p<PASSWORD> --all-databases > /backup/all_databases.sql
  22. # archiving of all backups to a single file
  23. tar -cvjpf /backup_`date +"%F"`.tar.bz2 /backup
  24. # send backup to another server
  25. scp /backup_`date +"%F"`.tar.bz2 user@server:/home/backup
  26. # remove local backup
  27. rm -R /backup /backup_`date +"%F"`.tar.bz2

update
backup from remote server 192.168.0.100 to local /mnt

mount /dev/sda1 /mnt/
rsync -aHxv root@192.168.0.100:/* /mnt --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp