From 87930d7d9d97490f8741b990d0351e23c267744f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 14 Jun 2019 16:52:23 -0300 Subject: [PATCH 01/65] Improving Contabo backup service times --- Services/backup-contabo-db.timer | 3 ++- Services/backup-contabo-files.timer | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo-db.timer index 4f75156..e6c3dbd 100644 --- a/Services/backup-contabo-db.timer +++ b/Services/backup-contabo-db.timer @@ -3,8 +3,9 @@ Description=Backup contabo db dayly [Timer] #DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=*-*-* 10:00:00 +OnCalendar=*-*-* 11:00:00 Persistent=true +AccuracySec=1h [Install] WantedBy=timers.target diff --git a/Services/backup-contabo-files.timer b/Services/backup-contabo-files.timer index 0e45f51..208390e 100644 --- a/Services/backup-contabo-files.timer +++ b/Services/backup-contabo-files.timer @@ -3,8 +3,9 @@ Description=Backup contabo files once per week [Timer] #DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=Mon *-*-* 11:00:00 +OnCalendar=Mon *-*-* 11:03:00 Persistent=true +AccuracySec=1h [Install] WantedBy=timers.target From e588f9685b79ca5110c09be49be6d6fcc2608564 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 14 Jun 2019 16:52:52 -0300 Subject: [PATCH 02/65] Updating with the changes on the external HD --- Backup/.Backup_HD_1TB.sh | 36 ++++++++++++++++-------------------- Backup/exclude | 4 ++++ Backup/runBackup.sh | 3 ++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index a93a742..a2ad1a6 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -1,11 +1,8 @@ YEARMONTH=`date +%Y/%m-%b` YEAR=`date +%Y` -HDPath="/run/media/bruno/Seagate\ Expansion\ Drive" +HDPath="/run/media/bruno/Seagate" HDYEARMONTH="$HDPath/$YEARMONTH" -White="\e[97m" -Gray="\e[39m" - mkdir -p "$HDPath/$YEAR" mkdir -p "$HDYEARMONTH" mkdir -p "$HDYEARMONTH/LinuxHome" @@ -23,37 +20,36 @@ echo echo Press enter key to start the backup read echo -echo -e "$White`date +%r` - Copying Dropbox folder (1/7)...$Gray" + +echo -e "\e[97m`date +%r` - Copying Dropbox folder (1/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" -echo -e "$White`date +%r` - Copying Linux Home folder (2/7)...$Gray" +echo -e "\e[97m`date +%r` - Copying Linux Home folder (2/7)...\e[39m" -echo -e "$White `date +%r` - Bruno$Gray" +echo -e "\e[97m `date +%r` - Bruno\e[39m" eval $backup "/home/bruno/" "$HDYEARMONTH/LinuxHome/bruno/" || echo "" -echo -e "$White `date +%r` - Admin$Gray" +echo -e "\e[97m `date +%r` - Admin\e[39m" eval $backup "/home/admin/" "$HDYEARMONTH/LinuxHome/admin/" || echo "" -echo -e "$White`date +%r` - Copying Localização folder (3/7)...$Gray" +echo -e "\e[97m `date +%r` - Lost+Found\e[39m" +eval $backup "/home/lost+found/" "$HDYEARMONTH/LinuxHome/lost+found/" || echo "" + +echo -e "\e[97m`date +%r` - Copying Localização folder (3/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Localização" "$HDYEARMONTH/Multimedia/" || echo "" -echo -e "$White`date +%r` - Copying My Documents folder (4/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/My\ Documents" "$HDYEARMONTH/Multimedia/" || echo "" +echo -e "\e[97m`date +%r` - Copying My Documents folder (4/7)...\e[39m" +eval $backup "/run/media/bruno/Multimedia/MyDocuments" "$HDYEARMONTH/Multimedia/" || echo "" -echo -e "$White`date +%r` - Copying Música folder (5/7)...$Gray" +echo -e "\e[97m`date +%r` - Copying Música folder (5/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Música" "$HDYEARMONTH/Multimedia/" || echo "" -echo -e "$White`date +%r` - Copying Fotos folder (6/7)...$Gray" +echo -e "\e[97m`date +%r` - Copying Fotos folder (6/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" -echo -e "$White`date +%r` - Copying Virtual Machines folder (7/7)...$Gray" +echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Virtual\ Machines" "$HDPath/$YEAR/" || echo "" -echo -e "$White`date +%r` - Backup finished. Please, verify your log files.$Gray" +echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" kdialog --title "Backup Complete" --msgbox "Backup finished successfully" - -echo -echo Press enter key to close -read - diff --git a/Backup/exclude b/Backup/exclude index 2c78ecf..6a5c148 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -1 +1,5 @@ .cache/* +Downloads/* +TransMit\ Tools\ -\ Studio\ 2015/* +Apps/* +shared/* diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 9d10a24..847657f 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash -terminator -m -T BACKUP -x systemd-inhibit sudo bash .Backup_HD_1TB.sh +terminator -m -T BACKUP -x time systemd-inhibit sudo bash .Backup_HD_1TB.sh; echo; echo "Press enter key to close"; read + From 257bcfebf693df3b11a29dbe01b5fc83ca7f947d Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 14 Jul 2019 19:43:15 -0300 Subject: [PATCH 03/65] Updating to run more times a day as I am using rsync now --- Services/backup-contabo-db.service | 0 Services/backup-contabo-db.timer | 3 +-- Services/backup-contabo-files.service | 0 Services/backup-contabo-files.timer | 2 +- 4 files changed, 2 insertions(+), 3 deletions(-) mode change 100644 => 100755 Services/backup-contabo-db.service mode change 100644 => 100755 Services/backup-contabo-db.timer mode change 100644 => 100755 Services/backup-contabo-files.service mode change 100644 => 100755 Services/backup-contabo-files.timer diff --git a/Services/backup-contabo-db.service b/Services/backup-contabo-db.service old mode 100644 new mode 100755 diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo-db.timer old mode 100644 new mode 100755 index e6c3dbd..9c31aed --- a/Services/backup-contabo-db.timer +++ b/Services/backup-contabo-db.timer @@ -2,8 +2,7 @@ Description=Backup contabo db dayly [Timer] -#DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=*-*-* 11:00:00 +OnCalendar=*-*-* 11:00:00,15:00:00 Persistent=true AccuracySec=1h diff --git a/Services/backup-contabo-files.service b/Services/backup-contabo-files.service old mode 100644 new mode 100755 diff --git a/Services/backup-contabo-files.timer b/Services/backup-contabo-files.timer old mode 100644 new mode 100755 index 208390e..33bcc15 --- a/Services/backup-contabo-files.timer +++ b/Services/backup-contabo-files.timer @@ -3,7 +3,7 @@ Description=Backup contabo files once per week [Timer] #DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=Mon *-*-* 11:03:00 +OnCalendar=*-*-* 11:03:00 Persistent=true AccuracySec=1h From dd5170b3b1fca0d4d965540e494f8c249a6969cc Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Mon, 15 Jul 2019 12:04:57 -0300 Subject: [PATCH 04/65] Avoind running pacman -Syyu as I am already updating with aurman --- Pacman/updateRepositories.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 128cf15..17f8977 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -21,8 +21,8 @@ s "pacman-mirrors -c Brazil" s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" #bold "Updating with PACMAN..." -s "echo" -yes | sudo pacman -Syyu --color always +#s "echo" +#yes | sudo pacman -Syyu --color always bold "Updating with AURMAN..." s "echo" From 428fe8ce78c4bd6307b7d3a0250fe672eb080188 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Mon, 15 Jul 2019 13:30:28 -0300 Subject: [PATCH 05/65] Organizing Backup scripts --- .gitignore | 4 ++++ Services/.localBackupPath_TEMPLATE | 1 + Services/.serverBackupPath_TEMPLATE | 1 + Services/.sshKey_TEMPLATE | 1 + Services/backup-db.sh | 9 +++++++++ Services/backup-files.sh | 9 +++++++++ 6 files changed, 25 insertions(+) create mode 100644 .gitignore create mode 100644 Services/.localBackupPath_TEMPLATE create mode 100644 Services/.serverBackupPath_TEMPLATE create mode 100644 Services/.sshKey_TEMPLATE create mode 100755 Services/backup-db.sh create mode 100755 Services/backup-files.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c50eed --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.localBackupPath +.serverBackupPath +.sshKeyBackupPath +.sshKey diff --git a/Services/.localBackupPath_TEMPLATE b/Services/.localBackupPath_TEMPLATE new file mode 100644 index 0000000..1c7c918 --- /dev/null +++ b/Services/.localBackupPath_TEMPLATE @@ -0,0 +1 @@ +/my/local/backup diff --git a/Services/.serverBackupPath_TEMPLATE b/Services/.serverBackupPath_TEMPLATE new file mode 100644 index 0000000..deca4eb --- /dev/null +++ b/Services/.serverBackupPath_TEMPLATE @@ -0,0 +1 @@ +sshBackupUser@serverIp:/my/backup/path diff --git a/Services/.sshKey_TEMPLATE b/Services/.sshKey_TEMPLATE new file mode 100644 index 0000000..156085f --- /dev/null +++ b/Services/.sshKey_TEMPLATE @@ -0,0 +1 @@ +/home/myUser/.ssh/id_rsa_backup diff --git a/Services/backup-db.sh b/Services/backup-db.sh new file mode 100755 index 0000000..0f71c5a --- /dev/null +++ b/Services/backup-db.sh @@ -0,0 +1,9 @@ +#! /bin/bash +sshKey=$(<.sshKey) +serverBackupPath=$(<.serverBackupPath) +localPath=$(<.localBackupPath) + +/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/db/*" "$localPath/db/" + +# Delete files older than 15 days +find "$localPath/db" -type f -name "*.sql.gz" -mtime +15 -delete diff --git a/Services/backup-files.sh b/Services/backup-files.sh new file mode 100755 index 0000000..6927cb6 --- /dev/null +++ b/Services/backup-files.sh @@ -0,0 +1,9 @@ +#! /bin/bash +sshKey=$(<.sshKey) +serverBackupPath=$(<.serverBackupPath) +localPath=$(<.localBackupPath) + +/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/files/*" "$localPath/files/" + +# Delete files older than 30 days +find "$localPath/files" -type f -name "*.*" -mtime +30 -delete From 3ad97db7e0a81fd4df87ef091c8f2b1ca82c58d3 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Mon, 15 Jul 2019 13:47:38 -0300 Subject: [PATCH 06/65] Fixing Backup Contabo DB.timer --- Services/backup-contabo-db.timer | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo-db.timer index 9c31aed..35c69bb 100755 --- a/Services/backup-contabo-db.timer +++ b/Services/backup-contabo-db.timer @@ -2,9 +2,10 @@ Description=Backup contabo db dayly [Timer] -OnCalendar=*-*-* 11:00:00,15:00:00 +OnCalendar=*-*-* 11:00:00 Persistent=true AccuracySec=1h +WakeSystem=true [Install] WantedBy=timers.target From 506646a0bafdb63ee510ee8fd604cd09277124fb Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Mon, 15 Jul 2019 13:48:02 -0300 Subject: [PATCH 07/65] Skipping updating with pacman as AURMAN updates all packages as well --- Pacman/updateRepositories.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 17f8977..dd2689c 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -20,9 +20,9 @@ bold "Pacman-mirrors -c" s "pacman-mirrors -c Brazil" s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" -#bold "Updating with PACMAN..." -#s "echo" -#yes | sudo pacman -Syyu --color always +# bold "Updating with PACMAN..." +# s "echo" +# yes | sudo pacman -Syyu --color always bold "Updating with AURMAN..." s "echo" From a4808a0e611486a0b18f13f4d26ac01b7498d00f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 16 Jul 2019 10:30:02 -0300 Subject: [PATCH 08/65] Including updating repos on aurman --- Pacman/updateRepositories.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index dd2689c..e91f70a 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -26,7 +26,7 @@ s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" bold "Updating with AURMAN..." s "echo" -aurman -Su --noedit --noconfirm --color always +aurman -Syyu --noedit --noconfirm --color always bold "Cleaning stuff..." s "echo" From 5799d5a332e36f621a37967584fb654528725b83 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 19 Jul 2019 15:54:14 -0300 Subject: [PATCH 09/65] Improving the script to use 2 HDs --- Backup/.Backup_HD_1TB.sh | 31 ++++++++++++++++++++++--------- Backup/.lastDisk | 1 + Backup/exclude | 1 + 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 Backup/.lastDisk diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index a2ad1a6..eff9c9e 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -1,16 +1,20 @@ YEARMONTH=`date +%Y/%m-%b` YEAR=`date +%Y` -HDPath="/run/media/bruno/Seagate" +HDPath="/run/media/bruno/Backup_" +LastDisk=$(< .lastDisk) + +if [ "$LastDisk" = '1' ]; then + NextDisk=2 +else + NextDisk=1 +fi + +backup="rsync -aq --inplace --exclude-from=./exclude" +HDPath="$HDPath$NextDisk" HDYEARMONTH="$HDPath/$YEARMONTH" -mkdir -p "$HDPath/$YEAR" -mkdir -p "$HDYEARMONTH" -mkdir -p "$HDYEARMONTH/LinuxHome" -mkdir -p "$HDYEARMONTH/LinuxHome/bruno" -mkdir -p "$HDYEARMONTH/LinuxHome/admin" -mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" - -backup="rsync -rptgoDql --exclude-from=./exclude" +# If folder does not exist, exit with error +[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$NextDisk before running this script." && exit 1 echo echo "Backup command : $backup" @@ -21,6 +25,14 @@ echo Press enter key to start the backup read echo +mkdir -p "$HDPath/$YEAR" +mkdir -p "$HDYEARMONTH" +mkdir -p "$HDYEARMONTH/LinuxHome" +mkdir -p "$HDYEARMONTH/LinuxHome/bruno" +mkdir -p "$HDYEARMONTH/LinuxHome/admin" +mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" + + echo -e "\e[97m`date +%r` - Copying Dropbox folder (1/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" @@ -52,4 +64,5 @@ eval $backup "/run/media/bruno/Multimedia/Virtual\ Machines" "$HDPath/$YEAR/" || echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" +echo "$NextDisk" > .lastDisk kdialog --title "Backup Complete" --msgbox "Backup finished successfully" diff --git a/Backup/.lastDisk b/Backup/.lastDisk new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Backup/.lastDisk @@ -0,0 +1 @@ +1 diff --git a/Backup/exclude b/Backup/exclude index 6a5c148..13610e8 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -3,3 +3,4 @@ Downloads/* TransMit\ Tools\ -\ Studio\ 2015/* Apps/* shared/* +.npm/* From 96220e593ecc6735327305d1d3eedc87ebee6d76 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 21 Jul 2019 02:40:34 -0300 Subject: [PATCH 10/65] Add script to check if there is internet connection or restart mobprobe --- Services/fixInternetAfterSleep.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 Services/fixInternetAfterSleep.sh diff --git a/Services/fixInternetAfterSleep.sh b/Services/fixInternetAfterSleep.sh new file mode 100755 index 0000000..5a9de9b --- /dev/null +++ b/Services/fixInternetAfterSleep.sh @@ -0,0 +1,4 @@ +if ! ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then + modProbeNumber=$(sudo dmesg | grep -m1 "enp1s0: link down" | awk '{if ($2 ~ /r[0-9].*/) { col=$2 } else { col=$3 }; gsub(":", "", col); print col }') + sudo modprobe -r "$modProbeNumber" && sleep 10 && sudo modprobe "$modProbeNumber" +fi From 8f16048878a5d137a901af819e0e6ff385a7150a Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 10:59:35 -0300 Subject: [PATCH 11/65] Adjusting timers and sleeps on contabo backups --- Services/backup-contabo-db.timer | 5 ++--- Services/backup-contabo-files.timer | 6 +++--- Services/backup-db.sh | 1 + Services/backup-files.sh | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo-db.timer index 35c69bb..c56753a 100755 --- a/Services/backup-contabo-db.timer +++ b/Services/backup-contabo-db.timer @@ -1,10 +1,9 @@ [Unit] -Description=Backup contabo db dayly +Description=Backup contabo db daily [Timer] -OnCalendar=*-*-* 11:00:00 Persistent=true -AccuracySec=1h +OnCalendar=*-*-* 10:00:00 WakeSystem=true [Install] diff --git a/Services/backup-contabo-files.timer b/Services/backup-contabo-files.timer index 33bcc15..c8025f3 100755 --- a/Services/backup-contabo-files.timer +++ b/Services/backup-contabo-files.timer @@ -2,10 +2,10 @@ Description=Backup contabo files once per week [Timer] -#DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=*-*-* 11:03:00 Persistent=true -AccuracySec=1h +OnCalendar=*-*-* 10:03:00 +WakeSystem=true +#DayOfWeek Year-Month-Day Hour:Minute:Second [Install] WantedBy=timers.target diff --git a/Services/backup-db.sh b/Services/backup-db.sh index 0f71c5a..167ee56 100755 --- a/Services/backup-db.sh +++ b/Services/backup-db.sh @@ -1,4 +1,5 @@ #! /bin/bash +sleep 50 sshKey=$(<.sshKey) serverBackupPath=$(<.serverBackupPath) localPath=$(<.localBackupPath) diff --git a/Services/backup-files.sh b/Services/backup-files.sh index 6927cb6..30e2f17 100755 --- a/Services/backup-files.sh +++ b/Services/backup-files.sh @@ -1,4 +1,5 @@ #! /bin/bash +sleep 60 sshKey=$(<.sshKey) serverBackupPath=$(<.serverBackupPath) localPath=$(<.localBackupPath) From 6093a485a205268f0b55896f8287149368267928 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 11:07:14 -0300 Subject: [PATCH 12/65] Organizing VPS backup --- Services/backup-contabo-db.service | 5 ----- Services/backup-contabo-db.timer | 10 ---------- Services/backup-contabo-files.service | 5 ----- Services/backup-contabo.service | 5 +++++ Services/backup-contabo.sh | 10 ++++++++++ ...backup-contabo-files.timer => backup-contabo.timer} | 4 ++-- Services/backup-db.sh | 10 ---------- Services/backup-files.sh | 10 ---------- 8 files changed, 17 insertions(+), 42 deletions(-) delete mode 100755 Services/backup-contabo-db.service delete mode 100755 Services/backup-contabo-db.timer delete mode 100755 Services/backup-contabo-files.service create mode 100755 Services/backup-contabo.service create mode 100755 Services/backup-contabo.sh rename Services/{backup-contabo-files.timer => backup-contabo.timer} (63%) delete mode 100755 Services/backup-db.sh delete mode 100755 Services/backup-files.sh diff --git a/Services/backup-contabo-db.service b/Services/backup-contabo-db.service deleted file mode 100755 index 83f2e7d..0000000 --- a/Services/backup-contabo-db.service +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Description=Backup contabo db daily - -[Service] -ExecStart=/home/bruno/Backups/Contabo/backup-db.sh diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo-db.timer deleted file mode 100755 index c56753a..0000000 --- a/Services/backup-contabo-db.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Backup contabo db daily - -[Timer] -Persistent=true -OnCalendar=*-*-* 10:00:00 -WakeSystem=true - -[Install] -WantedBy=timers.target diff --git a/Services/backup-contabo-files.service b/Services/backup-contabo-files.service deleted file mode 100755 index 01c813e..0000000 --- a/Services/backup-contabo-files.service +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Description=Backup contabo files once per week - -[Service] -ExecStart=/home/bruno/Backups/Contabo/backup-files.sh diff --git a/Services/backup-contabo.service b/Services/backup-contabo.service new file mode 100755 index 0000000..ede60f0 --- /dev/null +++ b/Services/backup-contabo.service @@ -0,0 +1,5 @@ +[Unit] +Description=Backup contabo daily + +[Service] +ExecStart=/home/bruno/Backups/Contabo/backup-contabo.sh diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh new file mode 100755 index 0000000..6cffdc0 --- /dev/null +++ b/Services/backup-contabo.sh @@ -0,0 +1,10 @@ +#! /bin/bash +sleep 60 +/bin/rsync -a -e "ssh -i /home/bruno/.ssh/id_rsa_backup" mybackup@167.86.78.36:/home/bruno/backups/* /home/bruno/Backups/Contabo/ + +# Delete old backups +find /home/bruno/Backups/Contabo/db -type f -name "*.sql.gz" -mtime +15 -delete +find /home/bruno/Backups/Contabo/files -type f -name "*.*" -mtime +35 -delete +find /home/bruno/Backups/Contabo/vmail -type f -name "*.*" -mtime +20 -delete + +find /home/bruno/Backups/Contabo/ -type f -name "*.*" -mtime +120 -delete diff --git a/Services/backup-contabo-files.timer b/Services/backup-contabo.timer similarity index 63% rename from Services/backup-contabo-files.timer rename to Services/backup-contabo.timer index c8025f3..1abd42f 100755 --- a/Services/backup-contabo-files.timer +++ b/Services/backup-contabo.timer @@ -1,9 +1,9 @@ [Unit] -Description=Backup contabo files once per week +Description=Backup contabo daily [Timer] Persistent=true -OnCalendar=*-*-* 10:03:00 +OnCalendar=*-*-* 10:15:00 WakeSystem=true #DayOfWeek Year-Month-Day Hour:Minute:Second diff --git a/Services/backup-db.sh b/Services/backup-db.sh deleted file mode 100755 index 167ee56..0000000 --- a/Services/backup-db.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -sleep 50 -sshKey=$(<.sshKey) -serverBackupPath=$(<.serverBackupPath) -localPath=$(<.localBackupPath) - -/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/db/*" "$localPath/db/" - -# Delete files older than 15 days -find "$localPath/db" -type f -name "*.sql.gz" -mtime +15 -delete diff --git a/Services/backup-files.sh b/Services/backup-files.sh deleted file mode 100755 index 30e2f17..0000000 --- a/Services/backup-files.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -sleep 60 -sshKey=$(<.sshKey) -serverBackupPath=$(<.serverBackupPath) -localPath=$(<.localBackupPath) - -/bin/rsync -r -e "ssh -i $sshKey" "$serverBackupPath/files/*" "$localPath/files/" - -# Delete files older than 30 days -find "$localPath/files" -type f -name "*.*" -mtime +30 -delete From c118eebbf4bfad1eac7b11c738db24ef67bd0fc9 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 11:22:32 -0300 Subject: [PATCH 13/65] Waits to make sure the system will be full reliable before running --- Services/fixInternetAfterSleep.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Services/fixInternetAfterSleep.sh b/Services/fixInternetAfterSleep.sh index 5a9de9b..2f7323f 100755 --- a/Services/fixInternetAfterSleep.sh +++ b/Services/fixInternetAfterSleep.sh @@ -1,3 +1,4 @@ +sleep 30 if ! ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then modProbeNumber=$(sudo dmesg | grep -m1 "enp1s0: link down" | awk '{if ($2 ~ /r[0-9].*/) { col=$2 } else { col=$3 }; gsub(":", "", col); print col }') sudo modprobe -r "$modProbeNumber" && sleep 10 && sudo modprobe "$modProbeNumber" From 0cb973041ca4883cdcc59ce9b3e81b8e9c287238 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 11:23:07 -0300 Subject: [PATCH 14/65] Including a Dolphin script to copy filenames --- Dolphin/bf-copy.desktop | 24 ++++++++++++++++++++++++ Dolphin/copyFullPath.sh | 7 +++++++ Dolphin/copyName.sh | 7 +++++++ Dolphin/copyPath.sh | 8 ++++++++ 4 files changed, 46 insertions(+) create mode 100644 Dolphin/bf-copy.desktop create mode 100644 Dolphin/copyFullPath.sh create mode 100644 Dolphin/copyName.sh create mode 100644 Dolphin/copyPath.sh diff --git a/Dolphin/bf-copy.desktop b/Dolphin/bf-copy.desktop new file mode 100644 index 0000000..bfbb2c4 --- /dev/null +++ b/Dolphin/bf-copy.desktop @@ -0,0 +1,24 @@ +# Copyright 2019 Bruno Fontes + +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +MimeType=application/octet-stream;inode/directory +Actions=copyNameOnly;copyPathOnly;copyPath; +X-KDE-Priority=TopLevel +X-KDE-Submenu=BFCopy + +[Desktop Action copyNameOnly] +Name=Copy Filename +Name[pt_BR]=Copiar nome do arquivo +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyName.sh %F + +[Desktop Action copyPathOnly] +Name=Copy Path +Name[pt_BR]=Copiar caminho +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyPath.sh %F + +[Desktop Action copyPath] +Name=Copy Full Path +Name[pt_BR]=Copiar caminho completo +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyFullPath.sh %F diff --git a/Dolphin/copyFullPath.sh b/Dolphin/copyFullPath.sh new file mode 100644 index 0000000..8e24ec5 --- /dev/null +++ b/Dolphin/copyFullPath.sh @@ -0,0 +1,7 @@ +#! /bin/bash +#printf "$@" | xsel -b -i +filelist="" +for line in "$@"; do + filelist="$filelist$line\n" +done +printf "$filelist" | xsel -b -i diff --git a/Dolphin/copyName.sh b/Dolphin/copyName.sh new file mode 100644 index 0000000..a260fc3 --- /dev/null +++ b/Dolphin/copyName.sh @@ -0,0 +1,7 @@ +#! /bin/bash +filelist="" +for line in "$@"; do + filename=$(basename -- "$line") + filelist="$filelist$filename\n" +done +printf "$filelist" | xsel -b -i diff --git a/Dolphin/copyPath.sh b/Dolphin/copyPath.sh new file mode 100644 index 0000000..bb113a6 --- /dev/null +++ b/Dolphin/copyPath.sh @@ -0,0 +1,8 @@ +#! /bin/bash +filelist="" +for line in "$@"; do + filename=$(basename -- "$line") + folder=${line%"$filename"} + filelist="$filelist$folder\n" +done +printf "$filelist" | xsel -b -i From f33fd3cf79a09068556dab0115d208c4af9aa0d7 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 11:23:29 -0300 Subject: [PATCH 15/65] Including Tizonia scripts --- music/start-tizonia-daemon.sh | 1 + music/start-tizonia.sh | 1 + 2 files changed, 2 insertions(+) create mode 100755 music/start-tizonia-daemon.sh create mode 100755 music/start-tizonia.sh diff --git a/music/start-tizonia-daemon.sh b/music/start-tizonia-daemon.sh new file mode 100755 index 0000000..7ee1fd3 --- /dev/null +++ b/music/start-tizonia-daemon.sh @@ -0,0 +1 @@ +/bin/tizonia --youtube-audio-playlist RDQMBgyfjGIyJlg --shuffle --daemon diff --git a/music/start-tizonia.sh b/music/start-tizonia.sh new file mode 100755 index 0000000..5e28912 --- /dev/null +++ b/music/start-tizonia.sh @@ -0,0 +1 @@ +/bin/tizonia --youtube-audio-playlist RDQMBgyfjGIyJlg --shuffle From 36d53be1af2099cdefce837331d60578e4d47ca3 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 13 Oct 2019 11:23:41 -0300 Subject: [PATCH 16/65] Small fixes at HD Backup script --- Backup/.Backup_HD_1TB.sh | 3 ++- Backup/.lastDisk | 2 +- Backup/runBackup.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index eff9c9e..e686140 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -9,7 +9,8 @@ else NextDisk=1 fi -backup="rsync -aq --inplace --exclude-from=./exclude" +#backup="rsync -aq --inplace --exclude-from=./exclude" +backup="nice -n 19 rsync -a --exclude-from=./exclude" HDPath="$HDPath$NextDisk" HDYEARMONTH="$HDPath/$YEARMONTH" diff --git a/Backup/.lastDisk b/Backup/.lastDisk index d00491f..0cfbf08 100644 --- a/Backup/.lastDisk +++ b/Backup/.lastDisk @@ -1 +1 @@ -1 +2 diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 847657f..a27ab46 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -terminator -m -T BACKUP -x time systemd-inhibit sudo bash .Backup_HD_1TB.sh; echo; echo "Press enter key to close"; read +#!/usr/bin/bash +terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh; echo; echo "Press enter key to close"; read From 626faf6ce28a7bb49c1ce237c43b37c67c3e26c7 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 24 Nov 2019 01:07:41 -0300 Subject: [PATCH 17/65] Including roothints update service for Unbound --- Services/roothints.service | 6 ++++++ Services/roothints.timer | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 Services/roothints.service create mode 100644 Services/roothints.timer diff --git a/Services/roothints.service b/Services/roothints.service new file mode 100644 index 0000000..c6d87af --- /dev/null +++ b/Services/roothints.service @@ -0,0 +1,6 @@ +[Unit] +Description=Update root hints for unbound +After=network.target + +[Service] +ExecStart=/usr/bin/curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache diff --git a/Services/roothints.timer b/Services/roothints.timer new file mode 100644 index 0000000..7a4c88c --- /dev/null +++ b/Services/roothints.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run root.hints monthly + +[Timer] +OnCalendar=monthly +Persistent=true + +[Install] +WantedBy=timers.target From 3a282512623f0a116a0282c35314747a36e6ac4c Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 6 May 2020 12:20:39 -0300 Subject: [PATCH 18/65] Including some dummy and messy scripts to Minecraft Just a service to inform time and closer Minecraft servers after some time, so kids are not going to sleep so late. --- Services/minecraft-hour.service | 6 ++++++ Services/minecraft-hour.sh | 23 +++++++++++++++++++++++ Services/minecraft-hour.timer | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100755 Services/minecraft-hour.service create mode 100755 Services/minecraft-hour.sh create mode 100755 Services/minecraft-hour.timer diff --git a/Services/minecraft-hour.service b/Services/minecraft-hour.service new file mode 100755 index 0000000..62f5a8b --- /dev/null +++ b/Services/minecraft-hour.service @@ -0,0 +1,6 @@ +[Unit] +Description=Minecraft Informa a Hora Certa + +[Service] +User=bruno +ExecStart=/bin/sh /home/bruno/Apps/linuxShortcuts/Services/minecraft-hour.sh diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh new file mode 100755 index 0000000..6c208b1 --- /dev/null +++ b/Services/minecraft-hour.sh @@ -0,0 +1,23 @@ +if ! screen -list | grep -q "minecraftPE"; then + exit 1 +fi + +function runAllWorlds () { + screen -S minecraftPESurvival -X stuff "$1" + screen -S minecraftPECreative -X stuff "$1" +} + +runAllWorlds "say $(date +%l:%M)\n" + +HORA=$(date +%H) +if [ "$HORA" -ge 23 ]; then + screen -S minecraftPECreative -X stuff $'say Hora de dormir\n' + sleep 5 + screen -S minecraftPECreative -X stuff $'stop\n' + + if [ "$HORA" -ge 1 -a "$HORA" -lt 5 ]; then + screen -S minecraftPESurvival -X stuff $'say Hora de dormir\n' + source /home/bruno/Apps/Minecraft/stopServers.sh + fi + +fi diff --git a/Services/minecraft-hour.timer b/Services/minecraft-hour.timer new file mode 100755 index 0000000..8846602 --- /dev/null +++ b/Services/minecraft-hour.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Minecraft Informa a Hora Certa +Requires=minecraft-hour.service + +[Timer] +Unit=minecraft-hour.service +OnCalendar=*-*-* *:0,15,30,45:00 +#DayOfWeek Year-Month-Day Hour:Minute:Second +AccuracySec=1s + +[Install] +WantedBy=timers.target From 95b5a30bcee4c98588ba3574a8d38249ff720983 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:01:29 -0300 Subject: [PATCH 19/65] Backup script updated 1. Moving message at the terminator command line, but inside the script itself. 2. Fixing mail backup filename on line to delete old backups --- Backup/.Backup_HD_1TB.sh | 4 ++++ Backup/runBackup.sh | 5 ++--- Services/backup-contabo.sh | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index e686140..04a4cfc 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -67,3 +67,7 @@ echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39 echo "$NextDisk" > .lastDisk kdialog --title "Backup Complete" --msgbox "Backup finished successfully" + +echo "Press any key to close" +read +exit diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index a27ab46..038cf7e 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1,3 +1,2 @@ -#!/usr/bin/bash -terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh; echo; echo "Press enter key to close"; read - +terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh +exit diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index 6cffdc0..9eb5c2c 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -5,6 +5,6 @@ sleep 60 # Delete old backups find /home/bruno/Backups/Contabo/db -type f -name "*.sql.gz" -mtime +15 -delete find /home/bruno/Backups/Contabo/files -type f -name "*.*" -mtime +35 -delete -find /home/bruno/Backups/Contabo/vmail -type f -name "*.*" -mtime +20 -delete +find /home/bruno/Backups/Contabo/mail -type f -name "*.*" -mtime +20 -delete find /home/bruno/Backups/Contabo/ -type f -name "*.*" -mtime +120 -delete From 7a4059035cb82ce119dfd4b6d5ee75eb6b9e958d Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:05:10 -0300 Subject: [PATCH 20/65] Backup: updating exclude file list --- Backup/exclude | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Backup/exclude b/Backup/exclude index 13610e8..d10f636 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -4,3 +4,7 @@ TransMit\ Tools\ -\ Studio\ 2015/* Apps/* shared/* .npm/* +bruno/Android/* +bruno/go/* +bruno/node_modules/* +Virtual\ Machines/projetomovase/* From 9ae24010912854e4ff0ccc38c2004fda6f73f246 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:06:22 -0300 Subject: [PATCH 21/65] Backup: tentative to umount external HD in the script at the end --- Backup/.Backup_HD_1TB.sh | 4 ++++ Backup/runBackup.sh | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index 04a4cfc..388f79d 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -70,4 +70,8 @@ kdialog --title "Backup Complete" --msgbox "Backup finished successfully" echo "Press any key to close" read + +#Umount device +device=$(mount | grep Backup_$LastDisk | cut -d " " -f1) +udisksctl unmount -b $device && udisksctl power-off -b $device exit diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 038cf7e..c5f7a14 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1,2 +1 @@ -terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh -exit +terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh & From dcc4511ebb64d18406f45e992d8703930851888e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:07:38 -0300 Subject: [PATCH 22/65] Minecraft: improving backup: 1. Now it uses just 1 screen session 2. Backup wait for the right trigger on log file to save --- Services/minecraft-hour.sh | 64 +++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 6c208b1..5c0c5f0 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -1,23 +1,57 @@ -if ! screen -list | grep -q "minecraftPE"; then +if ! screen -list | grep -q "Minecraft"; then exit 1 fi -function runAllWorlds () { - screen -S minecraftPESurvival -X stuff "$1" - screen -S minecraftPECreative -X stuff "$1" -} +BACKUPDIR="/home/bruno/Backups/Minecraft" +SERVERDIR="/home/bruno/Apps/Minecraft" +SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" +CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" +LogFile="log.txt" -runAllWorlds "say $(date +%l:%M)\n" +alias run='screen -S Minecraft -X' +alias runSurvival='run at Survival stuff' +alias runCreative='run at Creative stuff' +alias runAllWorlds='run at "#" stuff' -HORA=$(date +%H) -if [ "$HORA" -ge 23 ]; then - screen -S minecraftPECreative -X stuff $'say Hora de dormir\n' - sleep 5 - screen -S minecraftPECreative -X stuff $'stop\n' +cd /home/bruno/Apps/Minecraft - if [ "$HORA" -ge 1 -a "$HORA" -lt 5 ]; then - screen -S minecraftPESurvival -X stuff $'say Hora de dormir\n' - source /home/bruno/Apps/Minecraft/stopServers.sh +runAllWorlds "^u" +runAllWorlds "say $(date +%l:%M) - Saving worlds\n" +runAllWorlds "save hold\n" +sleep 2s + +finishedCreative="" +timeout=30 +while [[ $finishedCreative != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 fi + (( timeout-- )) + sleep 1s + runCreative "^u" + runCreative "save query\n" + finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") +done -fi +timeout=30 +finishedSurvival="" +while [[ $finishedSurvival != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Survival world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runSurvival "^u" + runSurvival "save query\n" + finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") +done + +BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") +mkdir "$BACKUPDIR/$BACKUPDATE" +/bin/tar cz --exclude=behavior_packs/* --exclude=resource_packs/* -f "$BACKUPDIR/$BACKUPDATE/Survival.tar.gz" "$SURVIVALDIR/worlds/Survival" +/bin/tar cz --exclude=behavior_packs/* --exclude=resource_packs/* -f "$BACKUPDIR/$BACKUPDATE/Creative.tar.gz" "$CREATIVEDIR/worlds/Creative" + +runAllWorlds "^u" +runAllWorlds "save resume\n" From bb74dec748cd5c3a38ed8b69d933a7ccc922f44f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:09:10 -0300 Subject: [PATCH 23/65] Arch update using only yay now --- Pacman/updateRepositories.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index e91f70a..bf0a6a1 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -20,13 +20,9 @@ bold "Pacman-mirrors -c" s "pacman-mirrors -c Brazil" s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" -# bold "Updating with PACMAN..." -# s "echo" -# yes | sudo pacman -Syyu --color always - bold "Updating with AURMAN..." s "echo" -aurman -Syyu --noedit --noconfirm --color always +yay -Syu --sudoloop --noconfirm --nobatchinstall bold "Cleaning stuff..." s "echo" From b159432dc2305e3b59f5214aa4ca316c11737626 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:09:43 -0300 Subject: [PATCH 24/65] PMova-se: script for using tmux to fast start dev --- tmuxStartPMOvase.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tmuxStartPMOvase.sh diff --git a/tmuxStartPMOvase.sh b/tmuxStartPMOvase.sh new file mode 100755 index 0000000..6e1e0c4 --- /dev/null +++ b/tmuxStartPMOvase.sh @@ -0,0 +1,34 @@ +#!/bin/zsh +cd /run/media/bruno/Multimedia/MyDocuments/Development/projetomovase +if [[ $(tmux ls | grep 'pmovase') ]]; then + terminator -T PMova-se -b --geometry=627x927 -x tmux a -t pmovase & + exit +fi + +echo "Iniciando Vagrant..." +tmux new -d -s pmovase + +tmux splitw -t pmovase +tmux splitw -t pmovase +tmux splitw -t pmovase +tmux splitw -h -t pmovase:0.1 + +terminator -T PMova-se -b --geometry=627x927 -x tmux a -t pmovase & + +tmux resize-pane -t pmovase:0.0 -U 30 +tmux resize-pane -t pmovase:0.1 -U 15 +tmux resize-pane -t pmovase:0.4 -U 10 + +tmux send -t pmovase:0.0 $'npm run vagrant; npm run watch\n' +tmux send -t pmovase:0.2 $'clear; Waiting for vagrant to start...\n' + +while [[ -z $(ping projetomovase.test -c 1 | grep "time=") ]] ; do + sleep 1 +done + +tmux send -t pmovase:0.1 $'npm run test-watch\n' +tmux send -t pmovase:0.2 $'^u' +tmux send -t pmovase:0.2 $'phpunit-watcher watch\n' +tmux send -t pmovase:0.3 $'ssh homestead -t \"cd code;clear; figlet Vagrant;bash --login\"\n' +tmux send -t pmovase:0.4 $'clear;figlet PMova-se\n' + From 670b6f18128d4b888b8330e67a995dd94c6f495e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 21 May 2020 16:11:14 -0300 Subject: [PATCH 25/65] Added: stupid 1 line script to turn off monitor For testing purposes only. --- turnOffMonitor.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 turnOffMonitor.sh diff --git a/turnOffMonitor.sh b/turnOffMonitor.sh new file mode 100755 index 0000000..52e751d --- /dev/null +++ b/turnOffMonitor.sh @@ -0,0 +1 @@ +xset -display :0.0 dpms force off From 35ed6782e6cc1a5d2d1c5169ce604f54fc5d400b Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 24 May 2020 11:06:30 -0300 Subject: [PATCH 26/65] Implementing zBackup to backups and organizing script --- .gitignore | 1 + Backup/.Backup_HD.sh | 99 ++++++++++++++++++++++++++++++++++++++ Backup/.Backup_HD_1TB.sh | 77 ----------------------------- Backup/exclude | 5 -- Backup/runBackup.sh | 2 +- Backup/zRestore.sh | 3 ++ Services/minecraft-hour.sh | 6 +-- 7 files changed, 107 insertions(+), 86 deletions(-) create mode 100755 Backup/.Backup_HD.sh delete mode 100755 Backup/.Backup_HD_1TB.sh create mode 100755 Backup/zRestore.sh diff --git a/.gitignore b/.gitignore index 6c50eed..58d7b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .serverBackupPath .sshKeyBackupPath .sshKey +Backup/.lastDisk diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh new file mode 100755 index 0000000..9e537bb --- /dev/null +++ b/Backup/.Backup_HD.sh @@ -0,0 +1,99 @@ +LastDisk=$(< .lastDisk) +if [ "$LastDisk" = '1' ]; then + ActiveDisk=2 +else + ActiveDisk=1 +fi + +YEAR=`date +%Y` +HDPath="/run/media/bruno/Backup_$ActiveDisk" + +ZBACKUP="$HDPath/`date +%Y-Q%q`" +YEARMONTH=`date +%m_%b-%d` +HDYEARMONTH="$ZBACKUP/backups/$YEARMONTH" + + +# If folder does not exist, exit with error +[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1 + +echo +echo "HD Backup path : $ZBACKUP" +echo "HD Year-Month path: $HDYEARMONTH" +echo +echo Press enter key to start the backup +read +echo + +if [ ! -d "$ZBACKUP" ]; then + mkdir -p "$ZBACKUP" + zbackup init --non-encrypted "$ZBACKUP" + + #If diskSpace less than ~100GB... + diskSpace=$(df --local --output=avail,target | grep "$HDPath\$" | awk '{ print $1}') + if [[ "$diskSpace" < 100000000 ]]; then + # delete oldest backup folder + oldestFolder=$(/bin/ls -dt "$HDPath"/????-Q? | tail -n 1) + echo + echo "$HDPath/$oldestFolder" + rm -rI "$HDPath/$oldestFolder" + fi +fi + +mkdir -p "$HDYEARMONTH" + +function backup () { + nice -n 19 tar c --exclude-ignore=.no-backup --add-file=.backup --exclude-from=./exclude "$1" | zbackup backup --non-encrypted --silent "$2" + zbackup restore --silent --non-encrypted "$2" > /dev/null 2> "$2"_status + if [[ $(cat "$2"_status) != "" ]]; then + echo -e "\033[1;31m ERROR UNPACKING $2 \033[0m" + fi +} + +echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m" +echo -e "\e[97m `date +%r` - Bruno\e[39m" +backup "/home/bruno/" "$HDYEARMONTH/LinuxHome-bruno" || echo "" + +echo -e "\e[97m `date +%r` - Admin\e[39m" +backup "/home/admin/" "$HDYEARMONTH/LinuxHome-admin" || echo "" + +echo -e "\e[97m `date +%r` - Lost+Found\e[39m" +backup "/home/lost+found/" "$HDYEARMONTH/LinuxHome-lost+found" || echo "" + +echo -e "\e[97m`date +%r` - Copying Localização folder (2/7)...\e[39m" +backup "/run/media/bruno/Multimedia/Localização/" "$HDYEARMONTH/Multimedia-localizacao" || echo "" + +echo -e "\e[97m`date +%r` - Copying My Documents folder (3/7)...\e[39m" +backup "/run/media/bruno/Multimedia/MyDocuments/" "$HDYEARMONTH/Multimedia-MyDocuments" || echo "" + +echo -e "\e[97m`date +%r` - Copying Música folder (4/7)...\e[39m" +backup "/run/media/bruno/Multimedia/Música/" "$HDYEARMONTH/Multimedia-musica" || echo "" + + +# Rsync Fotos e VMs +alias myrsync='nice -n 19 rsync -a' + +echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" +myrsync "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" + +echo -e "\e[97m`date +%r` - Copying Video folder (6/7)...\e[39m" +myrsync --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo "" + +echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" +myrsync "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo "" + + +# Show result +echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" + +echo "$ActiveDisk" > .lastDisk +device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) + +kdialog --title "Backup Complete" --msgbox "Backup finished successfully" +echo +echo "Backup on $device is finished. Press any key to close..." +read + + +#Try to umount device +udisksctl unmount -b "$device" && udisksctl power-off -b "$device" +exit diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh deleted file mode 100755 index 388f79d..0000000 --- a/Backup/.Backup_HD_1TB.sh +++ /dev/null @@ -1,77 +0,0 @@ -YEARMONTH=`date +%Y/%m-%b` -YEAR=`date +%Y` -HDPath="/run/media/bruno/Backup_" -LastDisk=$(< .lastDisk) - -if [ "$LastDisk" = '1' ]; then - NextDisk=2 -else - NextDisk=1 -fi - -#backup="rsync -aq --inplace --exclude-from=./exclude" -backup="nice -n 19 rsync -a --exclude-from=./exclude" -HDPath="$HDPath$NextDisk" -HDYEARMONTH="$HDPath/$YEARMONTH" - -# If folder does not exist, exit with error -[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$NextDisk before running this script." && exit 1 - -echo -echo "Backup command : $backup" -echo "HD Backup path : $HDPath" -echo "HD Year-Month path: $HDYEARMONTH" -echo -echo Press enter key to start the backup -read -echo - -mkdir -p "$HDPath/$YEAR" -mkdir -p "$HDYEARMONTH" -mkdir -p "$HDYEARMONTH/LinuxHome" -mkdir -p "$HDYEARMONTH/LinuxHome/bruno" -mkdir -p "$HDYEARMONTH/LinuxHome/admin" -mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" - - -echo -e "\e[97m`date +%r` - Copying Dropbox folder (1/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "\e[97m`date +%r` - Copying Linux Home folder (2/7)...\e[39m" - -echo -e "\e[97m `date +%r` - Bruno\e[39m" -eval $backup "/home/bruno/" "$HDYEARMONTH/LinuxHome/bruno/" || echo "" - -echo -e "\e[97m `date +%r` - Admin\e[39m" -eval $backup "/home/admin/" "$HDYEARMONTH/LinuxHome/admin/" || echo "" - -echo -e "\e[97m `date +%r` - Lost+Found\e[39m" -eval $backup "/home/lost+found/" "$HDYEARMONTH/LinuxHome/lost+found/" || echo "" - -echo -e "\e[97m`date +%r` - Copying Localização folder (3/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/Localização" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "\e[97m`date +%r` - Copying My Documents folder (4/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/MyDocuments" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "\e[97m`date +%r` - Copying Música folder (5/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/Música" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "\e[97m`date +%r` - Copying Fotos folder (6/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" - -echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -eval $backup "/run/media/bruno/Multimedia/Virtual\ Machines" "$HDPath/$YEAR/" || echo "" - -echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" - -echo "$NextDisk" > .lastDisk -kdialog --title "Backup Complete" --msgbox "Backup finished successfully" - -echo "Press any key to close" -read - -#Umount device -device=$(mount | grep Backup_$LastDisk | cut -d " " -f1) -udisksctl unmount -b $device && udisksctl power-off -b $device -exit diff --git a/Backup/exclude b/Backup/exclude index d10f636..129522d 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -1,10 +1,5 @@ .cache/* -Downloads/* -TransMit\ Tools\ -\ Studio\ 2015/* -Apps/* -shared/* .npm/* -bruno/Android/* bruno/go/* bruno/node_modules/* Virtual\ Machines/projetomovase/* diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index c5f7a14..53afbd5 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1 +1 @@ -terminator -m -T BACKUP -x sudo systemd-inhibit bash .Backup_HD_1TB.sh & +terminator -m -T BACKUP -x sudo systemd-inhibit bash /home/bruno/Apps/linuxShortcuts/Backup/.Backup_HD.sh & diff --git a/Backup/zRestore.sh b/Backup/zRestore.sh new file mode 100755 index 0000000..184ac26 --- /dev/null +++ b/Backup/zRestore.sh @@ -0,0 +1,3 @@ +date +zbackup --non-encrypted --silent --cache-size 512mb restore $1 > $2 +date diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 5c0c5f0..01a5bf7 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -2,7 +2,7 @@ if ! screen -list | grep -q "Minecraft"; then exit 1 fi -BACKUPDIR="/home/bruno/Backups/Minecraft" +BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" SERVERDIR="/home/bruno/Apps/Minecraft" SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" @@ -50,8 +50,8 @@ done BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") mkdir "$BACKUPDIR/$BACKUPDATE" -/bin/tar cz --exclude=behavior_packs/* --exclude=resource_packs/* -f "$BACKUPDIR/$BACKUPDATE/Survival.tar.gz" "$SURVIVALDIR/worlds/Survival" -/bin/tar cz --exclude=behavior_packs/* --exclude=resource_packs/* -f "$BACKUPDIR/$BACKUPDATE/Creative.tar.gz" "$CREATIVEDIR/worlds/Creative" +/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$SURVIVALDIR/worlds/Survival" | zbackup --nonencrypted backup "$BACKUPDIR/$BACKUPDATE-Survival" +/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$CREATIVEDIR/worlds/Creative" | zbackup --nonencrypted backup "$BACKUPDIR/$BACKUPDATE-Creative" runAllWorlds "^u" runAllWorlds "save resume\n" From 32671c462419f8aaa8f4b7b3e398e369c38510f3 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 24 May 2020 11:11:07 -0300 Subject: [PATCH 27/65] Fixing zbackup command on Minecraft Backup --- Services/minecraft-hour.sh | 4 ++-- Services/minecraft-stop.service | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 Services/minecraft-stop.service diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 01a5bf7..c1cc69f 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -50,8 +50,8 @@ done BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") mkdir "$BACKUPDIR/$BACKUPDATE" -/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$SURVIVALDIR/worlds/Survival" | zbackup --nonencrypted backup "$BACKUPDIR/$BACKUPDATE-Survival" -/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$CREATIVEDIR/worlds/Creative" | zbackup --nonencrypted backup "$BACKUPDIR/$BACKUPDATE-Creative" +/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$SURVIVALDIR/worlds/Survival" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE-Survival" +/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$CREATIVEDIR/worlds/Creative" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE-Creative" runAllWorlds "^u" runAllWorlds "save resume\n" diff --git a/Services/minecraft-stop.service b/Services/minecraft-stop.service new file mode 100755 index 0000000..97f71aa --- /dev/null +++ b/Services/minecraft-stop.service @@ -0,0 +1,11 @@ +[Unit] +Description=Properly shutdown Minecraft before PC shutdown + +[Service] +Type=oneshot +RemainAfterExit=true +User=bruno +ExecStop=/bin/sh /home/bruno/Apps/Minecraft/stopServers.sh + +[Install] +WantedBy=multi-user.target From d651d56726d43560f4c1538b93d4234eb42fcc36 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 24 May 2020 11:11:38 -0300 Subject: [PATCH 28/65] PMova-se: including clear alias and a screen version of script --- startPMovase.sh | 24 ++++++++++++++++++++++++ tmuxStartPMOvase.sh | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 startPMovase.sh diff --git a/startPMovase.sh b/startPMovase.sh new file mode 100755 index 0000000..4545ebd --- /dev/null +++ b/startPMovase.sh @@ -0,0 +1,24 @@ +cd /run/media/bruno/Multimedia/MyDocuments/Development/projetomovase +if [[ $(screen -ls | grep 'pmovase') ]]; then + echo "Já está rodando, saindo..." + exit +fi +echo "Iniciando Vagrant..." +screen -dmS pmovase +screen -S pmovase -p 0 -X stuff $'npm run vagrant; npm run watch\n' +screen -S pmovase -X screen +screen -S pmovase -X screen +sleep 2s +screen -S pmovase -p 2 -X title $'GIT' + +sleep 2m +screen -S pmovase -p 0 -X title $'NPM WATCH\n' +screen -S pmovase -p 1 -X stuff $'npm run ssh\n' +sleep 5s +screen -S pmovase -p 1 -X title $'Artisan' + +screen -S pmovase -X select 2 +screen -S pmovase -p 1 -X echo $'Done!\n' +screen -S pmovase -p 2 -X echo $'Done!\n' + +echo "Screen running. Attach to it with 'screen -r pmovase'" diff --git a/tmuxStartPMOvase.sh b/tmuxStartPMOvase.sh index 6e1e0c4..a811626 100755 --- a/tmuxStartPMOvase.sh +++ b/tmuxStartPMOvase.sh @@ -29,6 +29,6 @@ done tmux send -t pmovase:0.1 $'npm run test-watch\n' tmux send -t pmovase:0.2 $'^u' tmux send -t pmovase:0.2 $'phpunit-watcher watch\n' -tmux send -t pmovase:0.3 $'ssh homestead -t \"cd code;clear; figlet Vagrant;bash --login\"\n' -tmux send -t pmovase:0.4 $'clear;figlet PMova-se\n' +tmux send -t pmovase:0.3 $'ssh homestead -t \"cd code;alias clear='clear; figlet Vagrant';clear;bash --login\"\n' +tmux send -t pmovase:0.4 $'alias clear='clear;figlet PMova-se';clear\n' From 3b52ad3ae3699abdbc5ad6175b961bc2088900d4 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 2 Feb 2021 12:22:43 -0300 Subject: [PATCH 29/65] Improve backup menu removing issued alias to rsync --- Backup/.Backup_HD.sh | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index 9e537bb..dd50f69 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -1,3 +1,5 @@ +cd /home/bruno/Apps/linuxShortcuts/Backup/ + LastDisk=$(< .lastDisk) if [ "$LastDisk" = '1' ]; then ActiveDisk=2 @@ -12,16 +14,28 @@ ZBACKUP="$HDPath/`date +%Y-Q%q`" YEARMONTH=`date +%m_%b-%d` HDYEARMONTH="$ZBACKUP/backups/$YEARMONTH" - -# If folder does not exist, exit with error -[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1 - echo +echo "Disk : $ActiveDisk" echo "HD Backup path : $ZBACKUP" echo "HD Year-Month path: $HDYEARMONTH" echo -echo Press enter key to start the backup +echo "Please, insert Disk #$ActiveDisk and press enter to start backup" read + +timeout=30 +echo -n "Mounting Backup_$ActiveDisk" +device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) +while [[ "$device" != *"/dev/"* ]]; do + [[ $timeout -lt 1 ]] && echo -e "\e[97m Timeout!\e[39m" && break + (( timeout-- )) + echo -n "." + sleep 1s + device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) +done + +# If folder does not exist, exit with error +[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1 +echo ".OK!" echo if [ ! -d "$ZBACKUP" ]; then @@ -43,10 +57,12 @@ mkdir -p "$HDYEARMONTH" function backup () { nice -n 19 tar c --exclude-ignore=.no-backup --add-file=.backup --exclude-from=./exclude "$1" | zbackup backup --non-encrypted --silent "$2" + echo "`date +%r`- Checking the backup..." zbackup restore --silent --non-encrypted "$2" > /dev/null 2> "$2"_status if [[ $(cat "$2"_status) != "" ]]; then echo -e "\033[1;31m ERROR UNPACKING $2 \033[0m" fi + echo } echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m" @@ -70,23 +86,20 @@ backup "/run/media/bruno/Multimedia/Música/" "$HDYEARMONTH/Multimedia-musica" | # Rsync Fotos e VMs -alias myrsync='nice -n 19 rsync -a' - echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" -myrsync "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" +nice -n 19 rsync -a "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" echo -e "\e[97m`date +%r` - Copying Video folder (6/7)...\e[39m" -myrsync --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo "" +nice -n 19 rsync -a --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo "" echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -myrsync "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo "" +nice -n 19 rsync -a "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo "" # Show result echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" echo "$ActiveDisk" > .lastDisk -device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) kdialog --title "Backup Complete" --msgbox "Backup finished successfully" echo From 584b15b88beefd25837c242ab568cfc0340775ad Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 2 Feb 2021 23:02:06 -0300 Subject: [PATCH 30/65] Removes tizonia and spotify as I don't use them anymore --- music/spotify | 29 ----------------------------- music/start-tizonia-daemon.sh | 1 - music/start-tizonia.sh | 1 - 3 files changed, 31 deletions(-) delete mode 100755 music/spotify delete mode 100755 music/start-tizonia-daemon.sh delete mode 100755 music/start-tizonia.sh diff --git a/music/spotify b/music/spotify deleted file mode 100755 index cbaad9b..0000000 --- a/music/spotify +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -P|--play) - qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play - shift - ;; - -p|--pause) - qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause - shift - ;; - *) - echo "Usage:" - echo "-P (--play) - Play" - echo "-p (--pause) - Pause" - exit 3 - ;; -esac -done -if [[ $# -ne $1 ]]; then - echo "Usage:" - echo "-P (--play) - Play" - echo "-p (--pause) - Pause" -fi - diff --git a/music/start-tizonia-daemon.sh b/music/start-tizonia-daemon.sh deleted file mode 100755 index 7ee1fd3..0000000 --- a/music/start-tizonia-daemon.sh +++ /dev/null @@ -1 +0,0 @@ -/bin/tizonia --youtube-audio-playlist RDQMBgyfjGIyJlg --shuffle --daemon diff --git a/music/start-tizonia.sh b/music/start-tizonia.sh deleted file mode 100755 index 5e28912..0000000 --- a/music/start-tizonia.sh +++ /dev/null @@ -1 +0,0 @@ -/bin/tizonia --youtube-audio-playlist RDQMBgyfjGIyJlg --shuffle From 7424440645404852bac5a68d415aa8b564caeedf Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 19 Feb 2021 23:23:12 -0300 Subject: [PATCH 31/65] Improve security by removing password from variable --- Pacman/updateRepositories.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index bf0a6a1..1bb8f4c 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -6,26 +6,26 @@ function bold() { } function s() { - echo -e "$sudoPass\n" | sudo -S $1 + #echo -e "$sudoPass\n" | sudo --stdin $1 || exit 1 + sudo $1 echo } -sudo -k -echo -n Please type your sudo password: -read -s sudoPass + +# bold "Pacman-mirrors -c" +# s "pacman-mirrors -c Brazil" +# s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" + +s -v echo -s "echo '**********'" - -bold "Pacman-mirrors -c" -s "pacman-mirrors -c Brazil" -s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" - -bold "Updating with AURMAN..." -s "echo" -yay -Syu --sudoloop --noconfirm --nobatchinstall +bold "Updating..." +yay -Syu --sudoloop --noconfirm --nobatchinstall --cleanafter bold "Cleaning stuff..." -s "echo" +s -v yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always) +s -v +yay -Sc --noconfirm +s -k notify-send "Update script has finished!" From 60972813b0838ad81302682fefccfa6dc4eeffed Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 20 Feb 2021 09:45:15 -0300 Subject: [PATCH 32/65] Backup: avoid issues by including terminator path --- Backup/runBackup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 53afbd5..25e9156 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1 +1 @@ -terminator -m -T BACKUP -x sudo systemd-inhibit bash /home/bruno/Apps/linuxShortcuts/Backup/.Backup_HD.sh & +/bin/terminator -m -T BACKUP -x sudo systemd-inhibit bash /home/bruno/Apps/linuxShortcuts/Backup/.Backup_HD.sh & From b34416de141e729aaa968e42e84217001741b524 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 20 Feb 2021 14:55:12 -0300 Subject: [PATCH 33/65] Backup script now works on new server --- Services/backup-contabo.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index 9eb5c2c..c9e7cee 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -1,10 +1,15 @@ #! /bin/bash +if [[ -z $CONTABO_BACKUP_PATH ]]; then + echo CONTABO_BACKUP_PATH environment not set + exit 1 +fi sleep 60 -/bin/rsync -a -e "ssh -i /home/bruno/.ssh/id_rsa_backup" mybackup@167.86.78.36:/home/bruno/backups/* /home/bruno/Backups/Contabo/ +/bin/rsync --archive --exclude "files/nextcloud*" -e "ssh" backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH # Delete old backups -find /home/bruno/Backups/Contabo/db -type f -name "*.sql.gz" -mtime +15 -delete -find /home/bruno/Backups/Contabo/files -type f -name "*.*" -mtime +35 -delete -find /home/bruno/Backups/Contabo/mail -type f -name "*.*" -mtime +20 -delete +find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete +find $CONTABO_BACKUP_PATH/keys -type f -name "*.*" -mtime +15 -delete +find $CONTABO_BACKUP_PATH/files -type f -name "*.*" -mtime +35 -delete +find $CONTABO_BACKUP_PATH/mail -type f -name "*.*" -mtime +20 -delete -find /home/bruno/Backups/Contabo/ -type f -name "*.*" -mtime +120 -delete +find $CONTABO_BACKUP_PATH/ -type f -name "*.*" -mtime +120 -delete From 7a28fde055352e1824581bd227ead094a3a7e2be Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 23 Feb 2021 08:57:25 -0300 Subject: [PATCH 34/65] Joplin backup script --- Services/backup-joplin.service | 6 ++++++ Services/backup-joplin.sh | 15 +++++++++++++++ Services/backup-joplin.timer | 11 +++++++++++ 3 files changed, 32 insertions(+) create mode 100755 Services/backup-joplin.service create mode 100755 Services/backup-joplin.sh create mode 100755 Services/backup-joplin.timer diff --git a/Services/backup-joplin.service b/Services/backup-joplin.service new file mode 100755 index 0000000..98ba1b3 --- /dev/null +++ b/Services/backup-joplin.service @@ -0,0 +1,6 @@ +[Unit] +Description=Backup joplin weekly + +[Service] +User=bruno +ExecStart=/home/bruno/Apps/linuxShortcuts/Services/backup-joplin.sh diff --git a/Services/backup-joplin.sh b/Services/backup-joplin.sh new file mode 100755 index 0000000..3500a65 --- /dev/null +++ b/Services/backup-joplin.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +BACKUP_DIR="/home/bruno/Backups/Joplin" +JOPLIN_BIN="/bin/joplin" + +$JOPLIN_BIN sync +$JOPLIN_BIN e2ee decrypt + +# Delete old backups +cd "$BACKUP_DIR" +rm -r "./joplin.jex" +rm -rf "./MD" + +$JOPLIN_BIN --log-level debug export --format jex "$BACKUP_DIR/joplin.jex" +$JOPLIN_BIN --log-level debug export --format md "$BACKUP_DIR/MD" diff --git a/Services/backup-joplin.timer b/Services/backup-joplin.timer new file mode 100755 index 0000000..72f5630 --- /dev/null +++ b/Services/backup-joplin.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Backup joplin weekly + +[Timer] +Persistent=true +OnCalendar=Thu *-*-* 10:10:00 +WakeSystem=true +#DayOfWeek Year-Month-Day Hour:Minute:Second + +[Install] +WantedBy=timers.target From 2b36d7c555cd72fcf664a1c4f59d1ecebb9f3e11 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 23 Feb 2021 08:58:09 -0300 Subject: [PATCH 35/65] Backup does not start on metered connections anymore --- Services/backup-contabo.env | 1 + Services/backup-contabo.service | 1 + Services/backup-contabo.sh | 6 ++++++ 3 files changed, 8 insertions(+) create mode 100644 Services/backup-contabo.env mode change 100755 => 100644 Services/backup-contabo.service diff --git a/Services/backup-contabo.env b/Services/backup-contabo.env new file mode 100644 index 0000000..eb63459 --- /dev/null +++ b/Services/backup-contabo.env @@ -0,0 +1 @@ +CONTABO_BACKUP_PATH="/home/bruno/Backups/Contabo" diff --git a/Services/backup-contabo.service b/Services/backup-contabo.service old mode 100755 new mode 100644 index ede60f0..5db7fb2 --- a/Services/backup-contabo.service +++ b/Services/backup-contabo.service @@ -3,3 +3,4 @@ Description=Backup contabo daily [Service] ExecStart=/home/bruno/Backups/Contabo/backup-contabo.sh +EnvironmentFile=/home/bruno/Apps/linuxShortcuts/Services/backup-contabo.env diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index c9e7cee..5564231 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -1,4 +1,10 @@ #! /bin/bash + +if [[ `nmcli -t -f GENERAL.METERED dev show | grep "METERED:yes"` ]]; then + echo Backup does not work on metered connections + exit 1 +fi + if [[ -z $CONTABO_BACKUP_PATH ]]; then echo CONTABO_BACKUP_PATH environment not set exit 1 From 55a640cbf70c8e8817246ede7e230d2c5138f338 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 5 Mar 2021 12:23:27 -0300 Subject: [PATCH 36/65] Services logging errors --- Services/after-wakeup.service | 1 + Services/backup-contabo.service | 1 + Services/backup-joplin.service | 1 + Services/before-sleep.service | 1 + Services/logErrors@.service | 0 Services/minecraft-hour.service | 1 + Services/minecraft-stop.service | 1 + Services/roothints.service | 1 + Services/testDNS.service | 1 + Services/updateRootHints.service | 1 + 10 files changed, 9 insertions(+) mode change 100644 => 100755 Services/after-wakeup.service mode change 100644 => 100755 Services/backup-contabo.service mode change 100644 => 100755 Services/before-sleep.service mode change 100644 => 100755 Services/logErrors@.service mode change 100644 => 100755 Services/roothints.service mode change 100644 => 100755 Services/testDNS.service mode change 100644 => 100755 Services/updateRootHints.service diff --git a/Services/after-wakeup.service b/Services/after-wakeup.service old mode 100644 new mode 100755 index 9fdb467..53b1711 --- a/Services/after-wakeup.service +++ b/Services/after-wakeup.service @@ -1,6 +1,7 @@ [Unit] Description=Bruno Fontes script after wakeup After=suspend.target +OnFailure=logErrors@%n.service [Service] Type=simple diff --git a/Services/backup-contabo.service b/Services/backup-contabo.service old mode 100644 new mode 100755 index 5db7fb2..e5b714f --- a/Services/backup-contabo.service +++ b/Services/backup-contabo.service @@ -1,5 +1,6 @@ [Unit] Description=Backup contabo daily +OnFailure=logErrors@%n.service [Service] ExecStart=/home/bruno/Backups/Contabo/backup-contabo.sh diff --git a/Services/backup-joplin.service b/Services/backup-joplin.service index 98ba1b3..7a7634a 100755 --- a/Services/backup-joplin.service +++ b/Services/backup-joplin.service @@ -1,5 +1,6 @@ [Unit] Description=Backup joplin weekly +OnFailure=logErrors@%n.service [Service] User=bruno diff --git a/Services/before-sleep.service b/Services/before-sleep.service old mode 100644 new mode 100755 index 272fee2..d713ad2 --- a/Services/before-sleep.service +++ b/Services/before-sleep.service @@ -1,6 +1,7 @@ [Unit] Description=Bruno Fontes script before sleep Before=sleep.target +OnFailure=logErrors@%n.service [Service] Type=oneshot diff --git a/Services/logErrors@.service b/Services/logErrors@.service old mode 100644 new mode 100755 diff --git a/Services/minecraft-hour.service b/Services/minecraft-hour.service index 62f5a8b..d11612b 100755 --- a/Services/minecraft-hour.service +++ b/Services/minecraft-hour.service @@ -1,5 +1,6 @@ [Unit] Description=Minecraft Informa a Hora Certa +OnFailure=logErrors@%n.service [Service] User=bruno diff --git a/Services/minecraft-stop.service b/Services/minecraft-stop.service index 97f71aa..c75902c 100755 --- a/Services/minecraft-stop.service +++ b/Services/minecraft-stop.service @@ -1,5 +1,6 @@ [Unit] Description=Properly shutdown Minecraft before PC shutdown +OnFailure=logErrors@%n.service [Service] Type=oneshot diff --git a/Services/roothints.service b/Services/roothints.service old mode 100644 new mode 100755 index c6d87af..f6223c9 --- a/Services/roothints.service +++ b/Services/roothints.service @@ -1,6 +1,7 @@ [Unit] Description=Update root hints for unbound After=network.target +OnFailure=logErrors@%n.service [Service] ExecStart=/usr/bin/curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache diff --git a/Services/testDNS.service b/Services/testDNS.service old mode 100644 new mode 100755 index 9e1accf..d707c6f --- a/Services/testDNS.service +++ b/Services/testDNS.service @@ -2,6 +2,7 @@ Description=Test and fix DNS update with wrong time Wants=network-online.target After=network-online.target +OnFailure=logErrors@%n.service [Service] Type=oneshot diff --git a/Services/updateRootHints.service b/Services/updateRootHints.service old mode 100644 new mode 100755 index 10f0902..b4cd4f2 --- a/Services/updateRootHints.service +++ b/Services/updateRootHints.service @@ -1,5 +1,6 @@ [Unit] Description=Run update DNS root hints montly +OnFailure=logErrors@%n.service [Service] Type=oneshot From 3c0d5be76aa858775a37026828d06667c4d503ed Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 5 Mar 2021 12:24:30 -0300 Subject: [PATCH 37/65] Including temp change to backup main server --- Services/minecraft-hour.sh | 106 +++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index c1cc69f..044255e 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -1,57 +1,93 @@ -if ! screen -list | grep -q "Minecraft"; then - exit 1 +if screen -list | grep -q "MncftPublic"; then + publicBackup="true" +fi +if screen -list | grep -q "Minecraft"; then + otherBackup="true" +fi + +if [[ -z $publicBackup && -z $otherBackup ]] ; then + echo "Entrei" + exit 1 fi BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" SERVERDIR="/home/bruno/Apps/Minecraft" +PUBLICDIR="$SERVERDIR/BedrockServer_Public_19132" SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" LogFile="log.txt" +BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") +mkdir "$BACKUPDIR/$BACKUPDATE" + alias run='screen -S Minecraft -X' alias runSurvival='run at Survival stuff' alias runCreative='run at Creative stuff' +alias runPublic='screen -S MncftPublic -X at Server stuff' alias runAllWorlds='run at "#" stuff' cd /home/bruno/Apps/Minecraft runAllWorlds "^u" -runAllWorlds "say $(date +%l:%M) - Saving worlds\n" -runAllWorlds "save hold\n" +# runAllWorlds "say $(date +%l:%M) - Saving worlds\n" +runPublic "say ^usave hold\n" +runAllWorlds "^usave hold\n" sleep 2s -finishedCreative="" -timeout=30 -while [[ $finishedCreative != *"Data saved."* ]]; do - if [[ $timeout -lt 1 ]]; then - notify-send "Error backuping Creative world" - exit 1 - fi - (( timeout-- )) - sleep 1s + +if [[ $publicBackup ]]; then + echo Preparing public + finishedPublic="" + timeout=30 + while [[ $finishedPublic != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runPublic "say ^usave query\n" + finishedPublic=$(tail -n 4 "$PUBLICDIR/$LogFile") + done + /bin/tar c "$PUBLICDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/MncftPublic" + runPublic "say ^usave resume\n" +fi + +if [[ $otherBackup ]]; then + echo Preparing others + finishedCreative="" + timeout=30 + while [[ $finishedCreative != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runCreative "^u" + runCreative "save query\n" + finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") + done runCreative "^u" - runCreative "save query\n" - finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") -done + runCreative "save resume\n" -timeout=30 -finishedSurvival="" -while [[ $finishedSurvival != *"Data saved."* ]]; do - if [[ $timeout -lt 1 ]]; then - notify-send "Error backuping Survival world" - exit 1 - fi - (( timeout-- )) - sleep 1s + timeout=30 + finishedSurvival="" + while [[ $finishedSurvival != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Survival world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runSurvival "^u" + runSurvival "save query\n" + finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") + done + + /bin/tar c "$SURVIVALDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Survival" + /bin/tar c "$CREATIVEDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Creative" runSurvival "^u" - runSurvival "save query\n" - finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") -done + runSurvival "save resume\n" +fi -BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") -mkdir "$BACKUPDIR/$BACKUPDATE" -/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$SURVIVALDIR/worlds/Survival" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE-Survival" -/bin/tar c --exclude=behavior_packs/* --exclude=resource_packs/* "$CREATIVEDIR/worlds/Creative" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE-Creative" - -runAllWorlds "^u" -runAllWorlds "save resume\n" From e9d68361adf6181c1d67e0d215fc3c0df4e751a3 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 23 Mar 2021 23:00:13 -0300 Subject: [PATCH 38/65] Update backup to Borg Not using zbackup anymore as it is not being maintained. Borg appears to be a better replacement. --- Backup/.Backup_HD.sh | 84 ++++++++++++++++++++++++++++---------------- Backup/exclude | 33 ++++++++++++++--- 2 files changed, 82 insertions(+), 35 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index dd50f69..c14d257 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -1,3 +1,43 @@ +function backup () { + # $1 - Repository + # $2-$N - Files/Folders to backup + + #--stats = show stats at end + #--progress = show each file being processed + nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $* + checkBackup "$1" +} + +function checkBackup() { + echo -n "`date +%r`- Checking the backup..." + borg check "$1" > "$1"_status + if [[ $(cat "$1"_status) != "" ]]; then + echo -e "\n\033[1;31m ERROR UNPACKING $1 \033[0m" + else + echo ".OK!" + rm "$1"_status + fi + echo +} + +function verifyBackup() { + # Verify all data - takes long time + echo -n "`date +%r`- Checking the backup..." + borg check --verify-data "$1" > "$1"_status + if [[ $(cat "$1"_status) != "" ]]; then + echo -e "\n\033[1;31m ERROR UNPACKING $1 \033[0m" + else + echo ".OK!" + rm "$1"_status + fi + echo +} + +function pruneBackup() { + echo -e "\e[97m`date +%r` - Prune old backups...\e[39m" + borg prune -v --list --dry-run --keep-within=1m --keep-monthly=3 +} + cd /home/bruno/Apps/linuxShortcuts/Backup/ LastDisk=$(< .lastDisk) @@ -10,13 +50,13 @@ fi YEAR=`date +%Y` HDPath="/run/media/bruno/Backup_$ActiveDisk" -ZBACKUP="$HDPath/`date +%Y-Q%q`" +BACKUPPATH="$HDPath/`date +%Y-Q%q`" YEARMONTH=`date +%m_%b-%d` -HDYEARMONTH="$ZBACKUP/backups/$YEARMONTH" +HDYEARMONTH="$BACKUPPATH::$YEARMONTH" echo echo "Disk : $ActiveDisk" -echo "HD Backup path : $ZBACKUP" +echo "HD Backup path : $BACKUPPATH" echo "HD Year-Month path: $HDYEARMONTH" echo echo "Please, insert Disk #$ActiveDisk and press enter to start backup" @@ -38,9 +78,9 @@ done echo ".OK!" echo -if [ ! -d "$ZBACKUP" ]; then - mkdir -p "$ZBACKUP" - zbackup init --non-encrypted "$ZBACKUP" +if [ ! -d "$BACKUPPATH" ]; then + mkdir -p "$BACKUPPATH" + borg init --encryption=none $BACKUPPATH #If diskSpace less than ~100GB... diskSpace=$(df --local --output=avail,target | grep "$HDPath\$" | awk '{ print $1}') @@ -49,41 +89,27 @@ if [ ! -d "$ZBACKUP" ]; then oldestFolder=$(/bin/ls -dt "$HDPath"/????-Q? | tail -n 1) echo echo "$HDPath/$oldestFolder" - rm -rI "$HDPath/$oldestFolder" + rm --recursive --interactive=once "$HDPath/$oldestFolder" fi fi -mkdir -p "$HDYEARMONTH" - -function backup () { - nice -n 19 tar c --exclude-ignore=.no-backup --add-file=.backup --exclude-from=./exclude "$1" | zbackup backup --non-encrypted --silent "$2" - echo "`date +%r`- Checking the backup..." - zbackup restore --silent --non-encrypted "$2" > /dev/null 2> "$2"_status - if [[ $(cat "$2"_status) != "" ]]; then - echo -e "\033[1;31m ERROR UNPACKING $2 \033[0m" - fi - echo -} - echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m" echo -e "\e[97m `date +%r` - Bruno\e[39m" -backup "/home/bruno/" "$HDYEARMONTH/LinuxHome-bruno" || echo "" +backup "$HDYEARMONTH-LinuxHome-bruno" "/home/bruno/" || echo "" echo -e "\e[97m `date +%r` - Admin\e[39m" -backup "/home/admin/" "$HDYEARMONTH/LinuxHome-admin" || echo "" - -echo -e "\e[97m `date +%r` - Lost+Found\e[39m" -backup "/home/lost+found/" "$HDYEARMONTH/LinuxHome-lost+found" || echo "" +backup "$HDYEARMONTH-LinuxHome-admin" "/home/admin/" || echo "" echo -e "\e[97m`date +%r` - Copying Localização folder (2/7)...\e[39m" -backup "/run/media/bruno/Multimedia/Localização/" "$HDYEARMONTH/Multimedia-localizacao" || echo "" +backup "$HDYEARMONTH-Multimedia-localizacao" "/run/media/bruno/Multimedia/Localização/" || echo "" echo -e "\e[97m`date +%r` - Copying My Documents folder (3/7)...\e[39m" -backup "/run/media/bruno/Multimedia/MyDocuments/" "$HDYEARMONTH/Multimedia-MyDocuments" || echo "" +backup "$HDYEARMONTH-Multimedia-MyDocuments" "/run/media/bruno/Multimedia/MyDocuments/" || echo "" echo -e "\e[97m`date +%r` - Copying Música folder (4/7)...\e[39m" -backup "/run/media/bruno/Multimedia/Música/" "$HDYEARMONTH/Multimedia-musica" || echo "" +backup "$HDYEARMONTH-Multimedia-musica" "/run/media/bruno/Multimedia/Música/" || echo "" +verifyBackup "$BACKUPPATH" # Rsync Fotos e VMs echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" @@ -95,18 +121,16 @@ nice -n 19 rsync -a --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" nice -n 19 rsync -a "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo "" - # Show result echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" -echo "$ActiveDisk" > .lastDisk +echo "$ActiveDisk" > .lastDisk kdialog --title "Backup Complete" --msgbox "Backup finished successfully" echo echo "Backup on $device is finished. Press any key to close..." read - #Try to umount device udisksctl unmount -b "$device" && udisksctl power-off -b "$device" exit diff --git a/Backup/exclude b/Backup/exclude index 129522d..4520747 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -1,5 +1,28 @@ -.cache/* -.npm/* -bruno/go/* -bruno/node_modules/* -Virtual\ Machines/projetomovase/* +/home/bruno/.AndroidStudio3.1 +/home/bruno/.cache/ +/home/bruno/.electron +/home/bruno/.minecraft/ +/home/bruno/.netbeans +/home/bruno/.nixnote +/home/bruno/.node-gyp +/home/bruno/.npm +/home/bruno/.npm-global +/home/bruno/.openshot_qt +/home/bruno/.steam/ +/home/bruno/.tlauncher +/home/bruno/.vagrant.d/ +/home/bruno/.wine/ +/home/bruno/Android/ +/home/bruno/Apps/Minecraft/Backups/ +/home/bruno/Videos/ +/home/bruno/VirtualBox VMs/ +/home/bruno/bin/ +/home/bruno/go/ +/home/bruno/node_modules +/home/bruno/shared/ +/run/media/bruno/Multimedia/Localização/Ccaps/Projetos/@Delivered +/run/media/bruno/Multimedia/Localização/Ccaps/TEMP +/run/media/bruno/Multimedia/Localização/FONTES +/run/media/bruno/Multimedia/MyDocuments/Camtasia Studio +/run/media/bruno/Multimedia/MyDocuments/Downloads +/run/media/bruno/Multimedia/Virtual\ Machines From 8f19bc32d786688cbf107a37cc4f249922e5f5cc Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 23 Mar 2021 23:14:15 -0300 Subject: [PATCH 39/65] Including back pacman-mirrors --- Pacman/updateRepositories.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 1bb8f4c..cef8f1b 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -6,15 +6,14 @@ function bold() { } function s() { - #echo -e "$sudoPass\n" | sudo --stdin $1 || exit 1 sudo $1 echo } - -# bold "Pacman-mirrors -c" -# s "pacman-mirrors -c Brazil" -# s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" +s -v +bold "Pacman-mirrors -c" +s "pacman-mirrors -c Brazil" +s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" s -v echo From 578199a4eb329b1ce709c74fec3dbbc4a75bd701 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 25 Mar 2021 11:26:07 -0300 Subject: [PATCH 40/65] Backup: add script to list backups --- Backup/listBackups.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 Backup/listBackups.sh diff --git a/Backup/listBackups.sh b/Backup/listBackups.sh new file mode 100755 index 0000000..8234955 --- /dev/null +++ b/Backup/listBackups.sh @@ -0,0 +1,7 @@ +if [ $1 ]; then + sudo borg list $1 +else + echo + echo "ERROR: Backup folder argument is missing. Use folder name to display backup set or FOLDER_NAME::BACKUP_SET to display files." + echo +fi From 6cc4e48d659fcffad1d9774c3fabc00177986b9e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 25 Mar 2021 11:27:02 -0300 Subject: [PATCH 41/65] Backup: improve exclude list --- Backup/exclude | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Backup/exclude b/Backup/exclude index 4520747..b7a5d13 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -1,9 +1,10 @@ /home/bruno/.AndroidStudio3.1 /home/bruno/.cache/ /home/bruno/.electron +/home/bruno/.local/share/dino/files +/home/bruno/.local/share/gajim/downloads /home/bruno/.minecraft/ /home/bruno/.netbeans -/home/bruno/.nixnote /home/bruno/.node-gyp /home/bruno/.npm /home/bruno/.npm-global @@ -14,6 +15,7 @@ /home/bruno/.wine/ /home/bruno/Android/ /home/bruno/Apps/Minecraft/Backups/ +/home/bruno/Emulation/ /home/bruno/Videos/ /home/bruno/VirtualBox VMs/ /home/bruno/bin/ From 790e5f0d9b224cfbd051c6ea5f32c96d57af0853 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Thu, 25 Mar 2021 11:27:28 -0300 Subject: [PATCH 42/65] Backup: use only 2 repositories per disk It appears to be safe enough to have just a few repositories (2 per disk, 4 at total) to avoid backup corruption and it will increase a lot the disk space management and how long I will be able to keep my backups. --- Backup/.Backup_HD.sh | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index c14d257..90fe981 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -5,7 +5,6 @@ function backup () { #--stats = show stats at end #--progress = show each file being processed nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $* - checkBackup "$1" } function checkBackup() { @@ -20,24 +19,12 @@ function checkBackup() { echo } -function verifyBackup() { - # Verify all data - takes long time - echo -n "`date +%r`- Checking the backup..." - borg check --verify-data "$1" > "$1"_status - if [[ $(cat "$1"_status) != "" ]]; then - echo -e "\n\033[1;31m ERROR UNPACKING $1 \033[0m" - else - echo ".OK!" - rm "$1"_status - fi - echo -} - function pruneBackup() { echo -e "\e[97m`date +%r` - Prune old backups...\e[39m" - borg prune -v --list --dry-run --keep-within=1m --keep-monthly=3 + borg prune -v --list --dry-run --keep-weekly=8 --keep-monthly=12 --keep-yearly=3 $1 } + cd /home/bruno/Apps/linuxShortcuts/Backup/ LastDisk=$(< .lastDisk) @@ -47,11 +34,18 @@ else ActiveDisk=1 fi +LastBackupSet=$(< .lastBackupSetDisk_$lastDisk) +if [ "$LastBackupSet" = '1' ]; then + ActiveBackupSet=2 +else + ActiveBackupSet=1 +fi + YEAR=`date +%Y` HDPath="/run/media/bruno/Backup_$ActiveDisk" -BACKUPPATH="$HDPath/`date +%Y-Q%q`" -YEARMONTH=`date +%m_%b-%d` +BACKUPPATH="$HDPath/Repository_$ActiveBackupSet" +YEARMONTH=`date +%Y-%m-%d` HDYEARMONTH="$BACKUPPATH::$YEARMONTH" echo @@ -82,15 +76,8 @@ if [ ! -d "$BACKUPPATH" ]; then mkdir -p "$BACKUPPATH" borg init --encryption=none $BACKUPPATH - #If diskSpace less than ~100GB... - diskSpace=$(df --local --output=avail,target | grep "$HDPath\$" | awk '{ print $1}') - if [[ "$diskSpace" < 100000000 ]]; then - # delete oldest backup folder - oldestFolder=$(/bin/ls -dt "$HDPath"/????-Q? | tail -n 1) - echo - echo "$HDPath/$oldestFolder" - rm --recursive --interactive=once "$HDPath/$oldestFolder" - fi + #Prune old backups + pruneBackup $BACKUPPATH fi echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m" @@ -109,7 +96,7 @@ backup "$HDYEARMONTH-Multimedia-MyDocuments" "/run/media/bruno/Multimedia/MyDocu echo -e "\e[97m`date +%r` - Copying Música folder (4/7)...\e[39m" backup "$HDYEARMONTH-Multimedia-musica" "/run/media/bruno/Multimedia/Música/" || echo "" -verifyBackup "$BACKUPPATH" +checkBackup "$BACKUPPATH" # Rsync Fotos e VMs echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" @@ -125,6 +112,7 @@ nice -n 19 rsync -a "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEA echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" echo "$ActiveDisk" > .lastDisk +echo "$ActiveBackupSet" > ".lastBackupSetDisk_$lastDisk" kdialog --title "Backup Complete" --msgbox "Backup finished successfully" echo From e978b6a36e2dc89a12fd935689c62cac664bf25c Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 09:20:05 -0300 Subject: [PATCH 43/65] feat(backup): keeping just 1 repository per backup and testing it --- Backup/.Backup_HD.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index 90fe981..e48b8b2 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -7,6 +7,15 @@ function backup () { nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $* } +function backupNoCompression () { + # $1 - Repository + # $2-$N - Files/Folders to backup + + #--stats = show stats at end + #--progress = show each file being processed + nice -n 19 borg create --compression none --exclude-from=./exclude $* +} + function checkBackup() { echo -n "`date +%r`- Checking the backup..." borg check "$1" > "$1"_status @@ -34,17 +43,10 @@ else ActiveDisk=1 fi -LastBackupSet=$(< .lastBackupSetDisk_$lastDisk) -if [ "$LastBackupSet" = '1' ]; then - ActiveBackupSet=2 -else - ActiveBackupSet=1 -fi - YEAR=`date +%Y` HDPath="/run/media/bruno/Backup_$ActiveDisk" -BACKUPPATH="$HDPath/Repository_$ActiveBackupSet" +BACKUPPATH="$HDPath/Backup" YEARMONTH=`date +%Y-%m-%d` HDYEARMONTH="$BACKUPPATH::$YEARMONTH" @@ -100,13 +102,16 @@ checkBackup "$BACKUPPATH" # Rsync Fotos e VMs echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" -nice -n 19 rsync -a "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" +backupNoCompression "$HDPath/Fotos::$YEARMONTH" "/run/media/bruno/Multimedia/Fotos" || echo "" +checkBackup "$HDPath/Fotos/" echo -e "\e[97m`date +%r` - Copying Video folder (6/7)...\e[39m" -nice -n 19 rsync -a --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo "" +backupNoCompression "$HDPath/Videos::$YEARMONTH" "/run/media/bruno/Multimedia/Videos" || echo "" +checkBackup "$HDPath/Videos/" echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -nice -n 19 rsync -a "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo "" +backup "$HDPath/VirtualMachines::$YEARMONTH" "/run/media/bruno/Multimedia/Virtual\ Machines" || echo "" +checkBackup "$HDPath/VirtualMachines/" # Show result echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" From 9b3515d12169371d6cbcae5c42a524451ce39bc0 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 20:41:19 -0300 Subject: [PATCH 44/65] fix(Backup): folder name with space can be backed up Backup function were not working with folders that had space on it. Fixed now including double quotes with the parameter inside the function. --- Backup/.Backup_HD.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index e48b8b2..6835674 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -4,7 +4,7 @@ function backup () { #--stats = show stats at end #--progress = show each file being processed - nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $* + nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $1 "$2" } function backupNoCompression () { @@ -13,7 +13,7 @@ function backupNoCompression () { #--stats = show stats at end #--progress = show each file being processed - nice -n 19 borg create --compression none --exclude-from=./exclude $* + nice -n 19 borg create --compression none --exclude-from=./exclude $1 "$2" } function checkBackup() { @@ -110,7 +110,7 @@ backupNoCompression "$HDPath/Videos::$YEARMONTH" "/run/media/bruno/Multimedia/Vi checkBackup "$HDPath/Videos/" echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -backup "$HDPath/VirtualMachines::$YEARMONTH" "/run/media/bruno/Multimedia/Virtual\ Machines" || echo "" +backup "$HDPath/VirtualMachines::$YEARMONTH-2" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" checkBackup "$HDPath/VirtualMachines/" # Show result From d1ec197dc4f2f2c6ac0197ade402ebc3fa601857 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 20:43:52 -0300 Subject: [PATCH 45/65] fix(Backup): do not create unecessary file anymore --- Backup/.Backup_HD.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index 6835674..a58956f 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -117,7 +117,6 @@ checkBackup "$HDPath/VirtualMachines/" echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" echo "$ActiveDisk" > .lastDisk -echo "$ActiveBackupSet" > ".lastBackupSetDisk_$lastDisk" kdialog --title "Backup Complete" --msgbox "Backup finished successfully" echo From b8495afbbafb8624c6c5c96762a5a8cb6f4da71f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 20:52:56 -0300 Subject: [PATCH 46/65] fix(MinecraftBackup): exiting with the correct status It is expected to do not have a running instance so it should exit nicely. --- Services/minecraft-hour.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 044255e..4aba0be 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -6,8 +6,8 @@ if screen -list | grep -q "Minecraft"; then fi if [[ -z $publicBackup && -z $otherBackup ]] ; then - echo "Entrei" - exit 1 + echo "Minecraft is not running. Exiting..." + exit 0 fi BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" From f2095563b3b9c4ec0ca441ad90371eeac3cdbffa Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 21:18:30 -0300 Subject: [PATCH 47/65] feat(MinecraftBackup): now using Borg instead of zBackup --- Services/minecraft-hour.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 4aba0be..ddcefe9 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -10,7 +10,7 @@ if [[ -z $publicBackup && -z $otherBackup ]] ; then exit 0 fi -BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" +BACKUPDIR="/home/bruno/Backups/Minecraft-borg" SERVERDIR="/home/bruno/Apps/Minecraft" PUBLICDIR="$SERVERDIR/BedrockServer_Public_19132" SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" @@ -49,7 +49,7 @@ if [[ $publicBackup ]]; then runPublic "say ^usave query\n" finishedPublic=$(tail -n 4 "$PUBLICDIR/$LogFile") done - /bin/tar c "$PUBLICDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/MncftPublic" + borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftPublic" "$PUBLICDIR" runPublic "say ^usave resume\n" fi @@ -85,9 +85,9 @@ if [[ $otherBackup ]]; then finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") done - /bin/tar c "$SURVIVALDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Survival" - /bin/tar c "$CREATIVEDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Creative" + borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftSurvival" "$SURVIVALDIR" + borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftCreative" "$CREATIVEDIR" runSurvival "^u" runSurvival "save resume\n" fi - +borg prune --keep-within=3d --keep-hourly=96 --keep-weekly=8 --keep-monthly=6 "$BACKUPDIR" From c45afbc817b0d8bfc469d95ee328c70f537fb5eb Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 21:19:36 -0300 Subject: [PATCH 48/65] chore(tmuxPMovase): improve tmux organization/sizes --- tmuxStartPMOvase.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tmuxStartPMOvase.sh b/tmuxStartPMOvase.sh index a811626..3db8f4c 100755 --- a/tmuxStartPMOvase.sh +++ b/tmuxStartPMOvase.sh @@ -15,20 +15,24 @@ tmux splitw -h -t pmovase:0.1 terminator -T PMova-se -b --geometry=627x927 -x tmux a -t pmovase & -tmux resize-pane -t pmovase:0.0 -U 30 -tmux resize-pane -t pmovase:0.1 -U 15 +tmux resize-pane -t pmovase:0.0 -U 35 +tmux resize-pane -t pmovase:0.1 -U 10 tmux resize-pane -t pmovase:0.4 -U 10 tmux send -t pmovase:0.0 $'npm run vagrant; npm run watch\n' -tmux send -t pmovase:0.2 $'clear; Waiting for vagrant to start...\n' +tmux send -t pmovase:0.2 $'clear; echo Waiting for vagrant to start...\n' while [[ -z $(ping projetomovase.test -c 1 | grep "time=") ]] ; do - sleep 1 + sleep 5 done +sleep 10 +tmux send -t pmovase:0.1 $'npm run cypress:open\n' tmux send -t pmovase:0.1 $'npm run test-watch\n' tmux send -t pmovase:0.2 $'^u' -tmux send -t pmovase:0.2 $'phpunit-watcher watch\n' -tmux send -t pmovase:0.3 $'ssh homestead -t \"cd code;alias clear='clear; figlet Vagrant';clear;bash --login\"\n' -tmux send -t pmovase:0.4 $'alias clear='clear;figlet PMova-se';clear\n' +tmux send -t pmovase:0.2 $'npm run test-php-watch\n' +tmux send -t pmovase:0.3 $'npm run ssh\n' +tmux send -t pmovase:0.4 $'alias clear=\'clear;figlet PMova-se\';clear\n' +/bin/vscodium & +/home/bruno/Apps/firefox/firefox-bin & From b9ddb223e457a2dc7a499d6b2640883dbfb7a6c1 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 23:24:05 -0300 Subject: [PATCH 49/65] fix(Minecraft-hour.sh): do not create unecessary folder inside backup --- Services/minecraft-hour.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index ddcefe9..1c364b4 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -18,7 +18,6 @@ CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" LogFile="log.txt" BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") -mkdir "$BACKUPDIR/$BACKUPDATE" alias run='screen -S Minecraft -X' alias runSurvival='run at Survival stuff' From 3347cb35e6338034ba9d3dabf30432f02f78c7da Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 26 Mar 2021 23:32:49 -0300 Subject: [PATCH 50/65] feat(systemd): add shortcut to add new service The script removes an old version, copy the new service to the correct folder, run a daemon-reload and get a status about it. --- Services/installSystemService.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 Services/installSystemService.sh diff --git a/Services/installSystemService.sh b/Services/installSystemService.sh new file mode 100755 index 0000000..ed7f43c --- /dev/null +++ b/Services/installSystemService.sh @@ -0,0 +1,4 @@ +doas rm /etc/systemd/system/$1 +doas cp -f $1 /etc/systemd/system/ +doas systemctl daemon-reload +doas systemctl status $1 From d3fc0cecb65519c63f8e4e9014ae8fd339ad602e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 27 Mar 2021 11:38:50 -0300 Subject: [PATCH 51/65] fix(Backup): do not append a "-2" to the VM backup name anymore --- Backup/.Backup_HD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index a58956f..474161a 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -110,7 +110,7 @@ backupNoCompression "$HDPath/Videos::$YEARMONTH" "/run/media/bruno/Multimedia/Vi checkBackup "$HDPath/Videos/" echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -backup "$HDPath/VirtualMachines::$YEARMONTH-2" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" +backup "$HDPath/VirtualMachines::$YEARMONTH" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" checkBackup "$HDPath/VirtualMachines/" # Show result From fbb551377b7135580b039d35226348bb77bd88a4 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 3 Apr 2021 23:09:15 -0300 Subject: [PATCH 52/65] fix(backup): Each backup has it's own folder I was previously using one folder for multiple backups, but it doesn't help for pruning old backups. So, now, each backup set has it's own folder, what makes it easier to restore as well. --- Backup/.Backup_HD.sh | 104 +++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 48 deletions(-) diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh index 474161a..b8cb13a 100755 --- a/Backup/.Backup_HD.sh +++ b/Backup/.Backup_HD.sh @@ -1,36 +1,60 @@ +# Ansi color code variables +red="\e[0;91m" +blue="\e[0;94m" +expand_bg="\e[K" +blue_bg="\e[0;104m${expand_bg}" +red_bg="\e[0;101m${expand_bg}" +green_bg="\e[0;102m${expand_bg}" +green="\e[0;92m" +white="\e[0;97m" +bold="\e[1m" +uline="\e[4m" +reset="\e[0m" + function backup () { # $1 - Repository - # $2-$N - Files/Folders to backup - - #--stats = show stats at end - #--progress = show each file being processed - nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude $1 "$2" + # $2 - Backup name + # $3 - Files/Folders to backup + prepareFolder $1 + echo -e "${blue} `date +%r` - Backing up (compressed)...${reset}" + nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude "$1::$2" "$3" + checkBackup $1 } function backupNoCompression () { # $1 - Repository - # $2-$N - Files/Folders to backup + # $2 - Backup name + # $3 - Files/Folders to backup + prepareFolder $1 + echo -e "${blue} `date +%r` - Backing up (uncompressed)...${reset}" + nice -n 19 borg create --compression none --exclude-from=./exclude "$1::$2" "$3" + checkBackup $1 +} - #--stats = show stats at end - #--progress = show each file being processed - nice -n 19 borg create --compression none --exclude-from=./exclude $1 "$2" +function prepareFolder() { + if [ ! -d "$1" ]; then + mkdir -p "$1" + borg init --encryption=none $1 + else + pruneBackup $1 + fi } function checkBackup() { - echo -n "`date +%r`- Checking the backup..." + echo -e -n "${blue} `date +%r` - Checking the backup...${reset}" borg check "$1" > "$1"_status if [[ $(cat "$1"_status) != "" ]]; then echo -e "\n\033[1;31m ERROR UNPACKING $1 \033[0m" else - echo ".OK!" + echo -e ".${green}OK!${reset}" rm "$1"_status fi echo } function pruneBackup() { - echo -e "\e[97m`date +%r` - Prune old backups...\e[39m" - borg prune -v --list --dry-run --keep-weekly=8 --keep-monthly=12 --keep-yearly=3 $1 + echo -e "${blue} `date +%r` - Prune old backups...${reset}" + borg prune --keep-within=1y --keep-daily=30 --keep-weekly=12 --keep-monthly=24 --keep-yearly=3 $1 } @@ -48,12 +72,10 @@ HDPath="/run/media/bruno/Backup_$ActiveDisk" BACKUPPATH="$HDPath/Backup" YEARMONTH=`date +%Y-%m-%d` -HDYEARMONTH="$BACKUPPATH::$YEARMONTH" echo echo "Disk : $ActiveDisk" echo "HD Backup path : $BACKUPPATH" -echo "HD Year-Month path: $HDYEARMONTH" echo echo "Please, insert Disk #$ActiveDisk and press enter to start backup" read @@ -71,50 +93,36 @@ done # If folder does not exist, exit with error [ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1 -echo ".OK!" +echo -e ".${green}OK!${reset}" echo -if [ ! -d "$BACKUPPATH" ]; then - mkdir -p "$BACKUPPATH" - borg init --encryption=none $BACKUPPATH +echo -e "${white}`date +%r` - Copying Linux Home folder (1/7)...\e[39m" +echo -e "${white} `date +%r` - Bruno\e[39m" +backup "$HDPath/LinuxHome-Bruno" "$YEARMONTH" "/home/bruno/" || echo "" - #Prune old backups - pruneBackup $BACKUPPATH -fi +echo -e "${white} `date +%r` - Admin\e[39m" +backup "$HDPath/LinuxHome-Admin" "$YEARMONTH" "/home/admin/" || echo "" -echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m" -echo -e "\e[97m `date +%r` - Bruno\e[39m" -backup "$HDYEARMONTH-LinuxHome-bruno" "/home/bruno/" || echo "" +echo -e "${white}`date +%r` - Copying Localização folder (2/7)...\e[39m" +backup "$HDPath/Multimedia-Localizacao" "$YEARMONTH" "/run/media/bruno/Multimedia/Localização/" || echo "" -echo -e "\e[97m `date +%r` - Admin\e[39m" -backup "$HDYEARMONTH-LinuxHome-admin" "/home/admin/" || echo "" +echo -e "${white}`date +%r` - Copying My Documents folder (3/7)...\e[39m" +backup "$HDPath/Multimedia-MyDocuments" "$YEARMONTH" "/run/media/bruno/Multimedia/MyDocuments/" || echo "" -echo -e "\e[97m`date +%r` - Copying Localização folder (2/7)...\e[39m" -backup "$HDYEARMONTH-Multimedia-localizacao" "/run/media/bruno/Multimedia/Localização/" || echo "" +echo -e "${white}`date +%r` - Copying Música folder (4/7)...\e[39m" +backup "$HDPath/Multimedia-Musica" "$YEARMONTH" "/run/media/bruno/Multimedia/Música/" || echo "" -echo -e "\e[97m`date +%r` - Copying My Documents folder (3/7)...\e[39m" -backup "$HDYEARMONTH-Multimedia-MyDocuments" "/run/media/bruno/Multimedia/MyDocuments/" || echo "" +echo -e "${white}`date +%r` - Copying Fotos folder (5/7)...\e[39m" +backupNoCompression "$HDPath/Fotos" "$YEARMONTH" "/run/media/bruno/Multimedia/Fotos" || echo "" -echo -e "\e[97m`date +%r` - Copying Música folder (4/7)...\e[39m" -backup "$HDYEARMONTH-Multimedia-musica" "/run/media/bruno/Multimedia/Música/" || echo "" +echo -e "${white}`date +%r` - Copying Video folder (6/7)...\e[39m" +backupNoCompression "$HDPath/Videos" "$YEARMONTH" "/run/media/bruno/Multimedia/Videos" || echo "" -checkBackup "$BACKUPPATH" - -# Rsync Fotos e VMs -echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m" -backupNoCompression "$HDPath/Fotos::$YEARMONTH" "/run/media/bruno/Multimedia/Fotos" || echo "" -checkBackup "$HDPath/Fotos/" - -echo -e "\e[97m`date +%r` - Copying Video folder (6/7)...\e[39m" -backupNoCompression "$HDPath/Videos::$YEARMONTH" "/run/media/bruno/Multimedia/Videos" || echo "" -checkBackup "$HDPath/Videos/" - -echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" -backup "$HDPath/VirtualMachines::$YEARMONTH" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" -checkBackup "$HDPath/VirtualMachines/" +echo -e "${white}`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" +backup "$HDPath/VirtualMachines" "$YEARMONTH" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" # Show result -echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" +echo -e "${green}`date +%r` - Backup finished. Please, verify your log files.\e[39m" echo "$ActiveDisk" > .lastDisk From 7c8be4432ade6818bb8721c39c3f7b0d5f4a6b08 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 21 Apr 2021 18:03:22 -0300 Subject: [PATCH 53/65] update.sh: has fewer unecessary error messages --- Pacman/updateRepositories.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index cef8f1b..3cbe4f7 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -2,29 +2,27 @@ BOLD='\e[91m' NC='\e[39m' function bold() { - echo -e "${BOLD}$1${NC}" + echo -e "\n\n${BOLD}$1${NC}" } function s() { - sudo $1 - echo + sudo $* } s -v bold "Pacman-mirrors -c" -s "pacman-mirrors -c Brazil" -s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" +s "pacman-mirrors -c Brazil" 2>/dev/null +s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" 2>/dev/null s -v -echo bold "Updating..." yay -Syu --sudoloop --noconfirm --nobatchinstall --cleanafter bold "Cleaning stuff..." s -v -yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always) +yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always 2>/dev/null) s -v -yay -Sc --noconfirm +yay -Sc --noconfirm 2>/dev/null s -k notify-send "Update script has finished!" From 00a0ebe0f8f44acea2294e22685c6368b66dfd4f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 21 Apr 2021 18:23:10 -0300 Subject: [PATCH 54/65] update.sh: stop running if error when updating/cleaning --- Pacman/updateRepositories.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 3cbe4f7..22229ab 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -14,15 +14,18 @@ bold "Pacman-mirrors -c" s "pacman-mirrors -c Brazil" 2>/dev/null s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" 2>/dev/null +# From now on, exit when any command fails +set -e + s -v bold "Updating..." yay -Syu --sudoloop --noconfirm --nobatchinstall --cleanafter bold "Cleaning stuff..." s -v -yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always 2>/dev/null) -s -v yay -Sc --noconfirm 2>/dev/null +s -v +yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always 2>/dev/null) s -k notify-send "Update script has finished!" From 14901142b6a90e42337e87867274f2639513a5d0 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 17 Jul 2021 19:32:54 -0300 Subject: [PATCH 55/65] feat: add script to choose the best browser per KDE Activity --- browser.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 browser.sh diff --git a/browser.sh b/browser.sh new file mode 100755 index 0000000..5207ea6 --- /dev/null +++ b/browser.sh @@ -0,0 +1,7 @@ +#!/bin/sh +activity=`kactivities-cli --current-activity | cut -d" " -f3` + +[[ $activity == "OXO" ]] && /bin/brave "$1" +[[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" +[[ $activity == "Main" ]] && /bin/firefox "$1" +[[ $activity == "Videos" ]] && /bin/firefox "$1" From ebc7031a3d298900ebb542d0dd3be013f2111415 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 31 Jul 2021 16:14:03 -0300 Subject: [PATCH 56/65] feat(Browser): Include incognito window option --- browser.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/browser.sh b/browser.sh index 5207ea6..44c0600 100755 --- a/browser.sh +++ b/browser.sh @@ -1,7 +1,15 @@ -#!/bin/sh +#!/bin/bash activity=`kactivities-cli --current-activity | cut -d" " -f3` -[[ $activity == "OXO" ]] && /bin/brave "$1" -[[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" -[[ $activity == "Main" ]] && /bin/firefox "$1" -[[ $activity == "Videos" ]] && /bin/firefox "$1" +if [[ $1 =~ .*\&incognitottt$ ]]; then + url="${1/\&incognitottt/}" + [[ $activity == "OXO" ]] && /bin/brave --incognito "$url" 2>%1 1>/dev/null & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin --private-window "$url" 2>%1 1>/dev/null & + [[ $activity == "Main" ]] && /bin/firefox --private-window "$url" 2>%1 1>/dev/null & + [[ $activity == "Videos" ]] && /bin/firefox --private-window "$url" 2>%1 1>/dev/null & +else + [[ $activity == "OXO" ]] && /bin/brave "$1" 2>%1 1>/dev/null & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" 2>%1 1>/dev/null & + [[ $activity == "Main" ]] && /bin/firefox "$1" 2>%1 1>/dev/null & + [[ $activity == "Videos" ]] && /bin/firefox "$1" 2>%1 1>/dev/null & +fi From 0c16db897ffd22fe8ad8fc95e2e880bcc8782f48 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 4 Aug 2021 17:15:18 -0300 Subject: [PATCH 57/65] fix(browser): Fix typo redirecting errors do /dev/null --- browser.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/browser.sh b/browser.sh index 44c0600..f6cefc1 100755 --- a/browser.sh +++ b/browser.sh @@ -3,13 +3,13 @@ activity=`kactivities-cli --current-activity | cut -d" " -f3` if [[ $1 =~ .*\&incognitottt$ ]]; then url="${1/\&incognitottt/}" - [[ $activity == "OXO" ]] && /bin/brave --incognito "$url" 2>%1 1>/dev/null & - [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin --private-window "$url" 2>%1 1>/dev/null & - [[ $activity == "Main" ]] && /bin/firefox --private-window "$url" 2>%1 1>/dev/null & - [[ $activity == "Videos" ]] && /bin/firefox --private-window "$url" 2>%1 1>/dev/null & + [[ $activity == "OXO" ]] && /bin/brave --incognito "$url" >/dev/null 2>&1 & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin --private-window "$url" >/dev/null 2>&1 & + [[ $activity == "Main" ]] && /bin/firefox --private-window "$url" >/dev/null 2>&1 & + [[ $activity == "Videos" ]] && /bin/firefox --private-window "$url" >/dev/null 2>&1 & else - [[ $activity == "OXO" ]] && /bin/brave "$1" 2>%1 1>/dev/null & - [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" 2>%1 1>/dev/null & - [[ $activity == "Main" ]] && /bin/firefox "$1" 2>%1 1>/dev/null & - [[ $activity == "Videos" ]] && /bin/firefox "$1" 2>%1 1>/dev/null & + [[ $activity == "OXO" ]] && /bin/brave "$1" >/dev/null 2>&1 & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" >/dev/null 2>&1 & + [[ $activity == "Main" ]] && /bin/firefox "$1" >/dev/null 2>&1 & + [[ $activity == "Videos" ]] && /bin/firefox "$1" >/dev/null 2>&1 & fi From 847f839d892f7bb5203d53be483c8d22f2f6b643 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 4 Aug 2021 17:17:23 -0300 Subject: [PATCH 58/65] feat(video): Add script save last video path --- video.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 video.sh diff --git a/video.sh b/video.sh new file mode 100755 index 0000000..9ae016b --- /dev/null +++ b/video.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "$1" > ~/.lastVideo +/usr/bin/vlc --started-from-file "$1" 2>/dev/null & From b497912cdffd8d7dc033dfb37c91e5e1f5fb1899 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 4 Aug 2021 17:48:10 -0300 Subject: [PATCH 59/65] feat(OXO): script to stop Main activity when working --- KDE/OXO.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 KDE/OXO.sh diff --git a/KDE/OXO.sh b/KDE/OXO.sh new file mode 100755 index 0000000..15e4c56 --- /dev/null +++ b/KDE/OXO.sh @@ -0,0 +1,3 @@ +#!/bin/sh +kactivities-cli --stop-activity `kactivities-cli --list-activities | grep "Main" | cut -d' ' -f2` +notify-send --icon=`kactivities-cli --list-activities | grep "OXO" | cut -d' ' -f4` -a "OXO Innovation" "Main profile closed" From 42344f98a5ec105bbd97a3e1b7d5e4a2d8491817 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 22 Jan 2022 19:14:01 -0300 Subject: [PATCH 60/65] Tests, tests and tests Still not sure why I keep track of those changes, if I don't need them and do not care about proper handling them. Anyway, it is here if, some some reason I need it back. --- Backup/runBackup.sh | 1 + Dolphin/extract.desktop | 14 ++++++++ Dolphin/extract.sh | 23 +++++++++++++ Dolphin/{}-file | 0 Pacman/updateRepositories.sh | 5 +-- Screen/desktop.sh | 3 ++ Screen/new_laptop.sh | 5 +++ Screen/old_laptop.sh | 4 +++ Services/backup-contabo.sh | 9 ++++- Services/backup-joplin.sh | 2 +- Services/minecraft-hour.sh | 26 ++++++++------- Services/minecraft-server-public.sh | 50 ++++++++++++++++++++++++++++ Services/updateRootHints.service | 2 +- Services/xpra@.service | 11 +++++++ browser.sh | 5 +++ start-dashboard | 51 +++++++++++++++++++++++++++++ stop-pmovase.sh | 13 ++++++++ tmuxStartDicionarios.sh | 21 ++++++++++++ xrandr.sh | 3 ++ 19 files changed, 232 insertions(+), 16 deletions(-) create mode 100644 Dolphin/extract.desktop create mode 100755 Dolphin/extract.sh create mode 100644 Dolphin/{}-file create mode 100755 Screen/desktop.sh create mode 100755 Screen/new_laptop.sh create mode 100755 Screen/old_laptop.sh create mode 100644 Services/minecraft-server-public.sh create mode 100644 Services/xpra@.service create mode 100755 start-dashboard create mode 100755 stop-pmovase.sh create mode 100755 tmuxStartDicionarios.sh create mode 100755 xrandr.sh diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 25e9156..9082576 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1 +1,2 @@ +#!/bin/sh /bin/terminator -m -T BACKUP -x sudo systemd-inhibit bash /home/bruno/Apps/linuxShortcuts/Backup/.Backup_HD.sh & diff --git a/Dolphin/extract.desktop b/Dolphin/extract.desktop new file mode 100644 index 0000000..c169a71 --- /dev/null +++ b/Dolphin/extract.desktop @@ -0,0 +1,14 @@ +# Copyright 2019 Bruno Fontes + +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +MimeType=application/octet-stream;inode/directory +Actions=extract +X-KDE-Priority=TopLevel +X-KDE-Submenu=BFExtract + +[Desktop Action extract] +Name=Extract +Name[pt_BR]=Extrair +Exec=bash ~/.local/share/kservices5/ServiceMenus/extract.sh %F diff --git a/Dolphin/extract.sh b/Dolphin/extract.sh new file mode 100755 index 0000000..02b1392 --- /dev/null +++ b/Dolphin/extract.sh @@ -0,0 +1,23 @@ +#!/bin/bash +file="$1" +foldername="$(echo "$file" | sed 's/\(.*\)\..*/\1/')/" + +if [ -f "$file" ] ; then + case "$file" in + *.tar.bz2) tar xvjf "$file" -C "$foldername" ;; + *.tar.gz) tar xvzf "$file" -C "$foldername" ;; + *.bz2) bunzip2 "$file" "$foldername" ;; + *.rar) unrar x "$file" "$foldername" ;; + *.gz) gunzip "$file" "$foldername" ;; + *.tar) tar xvf "$file" -C "$foldername" ;; + *.tbz2) tar xvjf "$file" -C "$foldername" ;; + *.tgz) tar xvzf "$file" -C "$foldername" ;; + *.zip) unzip "$file" -d "$foldername" ;; + *.Z) uncompress "$file" "$foldername" ;; + *.7z) 7z x "$file" -o "$foldername" ;; + *) echo "'$file' cannot be extracted via >extract<" ;; + esac +else + echo "'$file' is not a valid file" +fi + diff --git a/Dolphin/{}-file b/Dolphin/{}-file new file mode 100644 index 0000000..e69de29 diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 22229ab..a29605d 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -10,8 +10,9 @@ function s() { } s -v -bold "Pacman-mirrors -c" -s "pacman-mirrors -c Brazil" 2>/dev/null +bold "Pacman-mirrors --continent" +s "pacman-mirrors --continent" 2>/dev/null +# s "pacman-mirrors -c Brazil" 2>/dev/null s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" 2>/dev/null # From now on, exit when any command fails diff --git a/Screen/desktop.sh b/Screen/desktop.sh new file mode 100755 index 0000000..9a5f6ae --- /dev/null +++ b/Screen/desktop.sh @@ -0,0 +1,3 @@ +#!/bin/sh +xrandr --output HDMI-1 --mode 1920x1080 +xrandr --output HDMI-2 --mode 1920x1080 diff --git a/Screen/new_laptop.sh b/Screen/new_laptop.sh new file mode 100755 index 0000000..6444fb6 --- /dev/null +++ b/Screen/new_laptop.sh @@ -0,0 +1,5 @@ +#!/bin/sh +setxkbmap -model abnt2 -layout br -variant ,abnt2 +xrandr --output HDMI-1 --mode 1280x720 #Max resolution monitor can do that fits blackout +xrandr --output HDMI-1 --mode 1366x768 #Max resolution monitor can do that fits blackout +xrandr --output HDMI-2 --mode 1366x768 diff --git a/Screen/old_laptop.sh b/Screen/old_laptop.sh new file mode 100755 index 0000000..e6cebb9 --- /dev/null +++ b/Screen/old_laptop.sh @@ -0,0 +1,4 @@ +#!/bin/sh +setxkbmap -model abnt2 -layout br -variant ,abnt2 +xrandr --output HDMI-1 --mode 1280x800 +xrandr --output HDMI-2 --mode 1280x800 diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index 5564231..d004fd1 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -10,7 +10,12 @@ if [[ -z $CONTABO_BACKUP_PATH ]]; then exit 1 fi sleep 60 -/bin/rsync --archive --exclude "files/nextcloud*" -e "ssh" backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH + +# Backup Contabo +/bin/rsync --archive --exclude "files/nextcloud*" --rsh=ssh backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH + +# Backup OXO +/bin/rsync --archive --rsh=ssh oxo:~/OXOwebsiteBackup.tar.gz ~/Backups/OXOwebsite/`date '+%Y-%m-%d'`_OXOwebsiteBackup.tar.gz # Delete old backups find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete @@ -19,3 +24,5 @@ find $CONTABO_BACKUP_PATH/files -type f -name "*.*" -mtime +35 -delete find $CONTABO_BACKUP_PATH/mail -type f -name "*.*" -mtime +20 -delete find $CONTABO_BACKUP_PATH/ -type f -name "*.*" -mtime +120 -delete + +find ~/Backups/OXOwebsite/ -type f -name "*.sql.gz" -mtime +15 -delete diff --git a/Services/backup-joplin.sh b/Services/backup-joplin.sh index 3500a65..a251259 100755 --- a/Services/backup-joplin.sh +++ b/Services/backup-joplin.sh @@ -1,7 +1,7 @@ #!/bin/bash BACKUP_DIR="/home/bruno/Backups/Joplin" -JOPLIN_BIN="/bin/joplin" +JOPLIN_BIN="/usr/bin/joplin" $JOPLIN_BIN sync $JOPLIN_BIN e2ee decrypt diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh index 1c364b4..16c9ab9 100755 --- a/Services/minecraft-hour.sh +++ b/Services/minecraft-hour.sh @@ -15,6 +15,7 @@ SERVERDIR="/home/bruno/Apps/Minecraft" PUBLICDIR="$SERVERDIR/BedrockServer_Public_19132" SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" +PATHTOBACKUP="" LogFile="log.txt" BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") @@ -40,16 +41,18 @@ if [[ $publicBackup ]]; then timeout=30 while [[ $finishedPublic != *"Data saved."* ]]; do if [[ $timeout -lt 1 ]]; then - notify-send "Error backuping Creative world" + notify-send "Error backuping Public world" + echo "Error Public $timeout" exit 1 fi (( timeout-- )) sleep 1s - runPublic "say ^usave query\n" + echo $tmeout + runPublic "^usave query\n" finishedPublic=$(tail -n 4 "$PUBLICDIR/$LogFile") + PATHTOBACKUP="$PATHTOBACKUP \"$PUBLICDIR\"" done - borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftPublic" "$PUBLICDIR" - runPublic "say ^usave resume\n" + echo "Passou Public" fi if [[ $otherBackup ]]; then @@ -67,8 +70,7 @@ if [[ $otherBackup ]]; then runCreative "save query\n" finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") done - runCreative "^u" - runCreative "save resume\n" + PATHTOBACKUP="$PATHTOBACKUP \"$CREATIVEDIR\"" timeout=30 finishedSurvival="" @@ -83,10 +85,12 @@ if [[ $otherBackup ]]; then runSurvival "save query\n" finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") done - - borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftSurvival" "$SURVIVALDIR" - borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftCreative" "$CREATIVEDIR" - runSurvival "^u" - runSurvival "save resume\n" + PATHTOBACKUP="$PATHTOBACKUP \"$SURVIVALDIR\"" fi + +[[ $PATHTOBACKUP ]] && borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE" "$PATHTOBACKUP" + +[[ $publicBackup ]] && runPublic "say ^usave resume\n" +[[ $otherBackup ]] && runSurvival "say ^usave resume\n" && runCreative "say ^usave resume\n" + borg prune --keep-within=3d --keep-hourly=96 --keep-weekly=8 --keep-monthly=6 "$BACKUPDIR" diff --git a/Services/minecraft-server-public.sh b/Services/minecraft-server-public.sh new file mode 100644 index 0000000..36b8308 --- /dev/null +++ b/Services/minecraft-server-public.sh @@ -0,0 +1,50 @@ +if ! screen -list | grep -q "Minecraft"; then + exit 1 +fi + +BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" +SERVERDIR="/home/bruno/Apps/Minecraft/BedrockServer_Public_19132" +LogFile="log.txt" + +alias run='screen -S MinecraftPublic -X' +alias runAllWorlds='run at "#" stuff' + +runAllWorlds "^u" +runAllWorlds "save hold\n" +sleep 2s + +finishedCreative="" +timeout=30 +while [[ $finishedCreative != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runCreative "^u" + runCreative "save query\n" + finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") +done + +timeout=30 +finishedSurvival="" +while [[ $finishedSurvival != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Survival world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runSurvival "^u" + runSurvival "save query\n" + finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") +done + +BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") +mkdir "$BACKUPDIR/$BACKUPDATE" +/bin/tar c "$SURVIVALDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Survival" +/bin/tar c "$CREATIVEDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Creative" + +runAllWorlds "^u" +runAllWorlds "save resume\n" diff --git a/Services/updateRootHints.service b/Services/updateRootHints.service index b4cd4f2..13fbb1d 100755 --- a/Services/updateRootHints.service +++ b/Services/updateRootHints.service @@ -4,4 +4,4 @@ OnFailure=logErrors@%n.service [Service] Type=oneshot -ExecStart = /bin/bash /home/bruno/dns_update_rootHints.sh +ExecStart = /bin/bash /home/bruno/Apps/linuxShortcuts/Services/roothints.sh diff --git a/Services/xpra@.service b/Services/xpra@.service new file mode 100644 index 0000000..bac1950 --- /dev/null +++ b/Services/xpra@.service @@ -0,0 +1,11 @@ +[Unit] +Description=xpra display + +[Service] +Type=simple +User=%i +EnvironmentFile=/etc/conf.d/xpra +ExecStart=/usr/bin/xpra --no-daemon start ${%i} + +[Install] +WantedBy=multi-user.target diff --git a/browser.sh b/browser.sh index f6cefc1..2f2d966 100755 --- a/browser.sh +++ b/browser.sh @@ -1,6 +1,11 @@ #!/bin/bash activity=`kactivities-cli --current-activity | cut -d" " -f3` +if [[ $1 =~ .*youtube\.com.* ]]; then + /bin/freetube "$*" >/dev/null 2>&1 & + exit +fi + if [[ $1 =~ .*\&incognitottt$ ]]; then url="${1/\&incognitottt/}" [[ $activity == "OXO" ]] && /bin/brave --incognito "$url" >/dev/null 2>&1 & diff --git a/start-dashboard b/start-dashboard new file mode 100755 index 0000000..b7fed0a --- /dev/null +++ b/start-dashboard @@ -0,0 +1,51 @@ +#!/bin/sh + +if [[ $(tmux ls | grep 'dashboard') ]]; then + terminator -T "Dashboard" -x tmux a -t dashboard & + exit +fi +echo "Iniciando Dashboard..." +sleep 2 +tmux new -d -s dashboard +tmux rename-window -t dashboard "Dashboard" +terminator -T "Dashboard" -x tmux a -t dashboard & +sleep 10 +tmux splitw -t dashboard +tmux splitw -h -t dashboard:0.0 +tmux resize-pane -U -t dashboard:0.2 15 +tmux resize-pane -L -t dashboard:0.1 10 +sleep 1 + +# 0 - Dashboard/khal +tmux send -t dashboard:0.0 $'clear;watch --interval $((30 * 60)) --no-title --color screenfetch\n' +tmux send -t dashboard:0.1 $'alias clear="clear;figlet Dashboard; echo -n Khal:\ ; khal list; echo;"\n' +tmux send -t dashboard:0.2 $'btop\n' +tmux send -t dashboard:0.1 $'clear\n' + +# 1 - Tut +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:1.0 $'tut\n' +tmux rename-window -t dashboard:1 tut +tmux setw monitor-activity -t dashboard:1 + +# 2 - GoMuks +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:2.0 $'gomuks\n' +tmux rename-window -t dashboard:2 gomuks + +# 3 - NeoMutt +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:3.0 $'neomutt\n' +tmux rename-window -t dashboard:3 neomutt + +# 4 - Joplin +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:4.0 $'joplin\n' +tmux rename-window -t dashboard:4 joplin + +tmux select-window -t dashboard:0 +tmux setw monitor-silence -t dashboard:0 diff --git a/stop-pmovase.sh b/stop-pmovase.sh new file mode 100755 index 0000000..b4a3044 --- /dev/null +++ b/stop-pmovase.sh @@ -0,0 +1,13 @@ +#!/bin/zsh +#if [[ !$(tmux ls | grep 'pmovase') ]]; then +# exit +#fi + +killall /home/bruno/Apps/firefox/firefox-bin +killall /bin/vscodium + +cd /home/bruno/development/projetomovase/ +vagrant suspend +tmux send -t pmovase:0.4 $'^u' +#tmux send -t pmovase:0.4 $'vagrant suspend &\n' +tmux kill-session -t pmovase diff --git a/tmuxStartDicionarios.sh b/tmuxStartDicionarios.sh new file mode 100755 index 0000000..97eeb9a --- /dev/null +++ b/tmuxStartDicionarios.sh @@ -0,0 +1,21 @@ +#!/bin/zsh + +projectName=dicionarioscc +cd /run/media/bruno/Multimedia/MyDocuments/Development/BrunoFontes/dicionarios.cc/ +if [[ $(tmux ls | grep '$projectName') ]]; then + uxterm -T $projectName -geometry 627x927 -e tmux a -t $projectName & + exit +fi + +tmux new -d -s $projectName + +tmux splitw -ht $projectName +tmux splitw -vt $projectName:0.1 +tmux splitw -vt $projectName:0.2 + +uxterm -T $projectName -geometry 627x927 -e tmux a -t $projectName & + +tmux send -t $projectName:0.0 $'nvim\n' +tmux send -t $projectName:0.1 $'make dev\n' +tmux send -t $projectName:0.2 $'tail -f src/dicio.log\n' +tmux send -t $projectName:0.3 $'gss\n' diff --git a/xrandr.sh b/xrandr.sh new file mode 100755 index 0000000..3cc2711 --- /dev/null +++ b/xrandr.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +xrandr --output HDMI-2 --left-of HDMI-1 From 8fe43eb4042f2765c948cbe87c7486074d21235c Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 1 Feb 2022 21:45:08 -0300 Subject: [PATCH 61/65] Adding Gitea to backup --- Services/backup-contabo.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index d004fd1..78a1cde 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -17,6 +17,9 @@ sleep 60 # Backup OXO /bin/rsync --archive --rsh=ssh oxo:~/OXOwebsiteBackup.tar.gz ~/Backups/OXOwebsite/`date '+%Y-%m-%d'`_OXOwebsiteBackup.tar.gz +# Backup Gitea +/bin/rsync --archive --rsh=ssh googlemicro:~/ttt/*.zip ~/Backups/gitea/`date '+%Y-%m-%d'`_gitea.zip + # Delete old backups find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete find $CONTABO_BACKUP_PATH/keys -type f -name "*.*" -mtime +15 -delete From 9d973a0305a7264327cdc5a44dee1e45cde86201 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 20 Feb 2022 19:01:56 -0300 Subject: [PATCH 62/65] yay: show pkgbuild diff --- Pacman/updateRepositories.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index a29605d..da3615d 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -20,7 +20,7 @@ set -e s -v bold "Updating..." -yay -Syu --sudoloop --noconfirm --nobatchinstall --cleanafter +yay -Syu --sudoloop --answerclean none --answerdiff all --answerupgrade none --noremovemake --nobatchinstall --cleanafter]] bold "Cleaning stuff..." s -v From bfd0749b1168564e0c7a4adc246c6b6aaaa7dc3e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 20 Feb 2022 19:03:43 -0300 Subject: [PATCH 63/65] BackupServer: adding/fixing other backups --- Services/backup-contabo.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh index 78a1cde..e713cb3 100755 --- a/Services/backup-contabo.sh +++ b/Services/backup-contabo.sh @@ -12,20 +12,27 @@ fi sleep 60 # Backup Contabo -/bin/rsync --archive --exclude "files/nextcloud*" --rsh=ssh backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH - -# Backup OXO -/bin/rsync --archive --rsh=ssh oxo:~/OXOwebsiteBackup.tar.gz ~/Backups/OXOwebsite/`date '+%Y-%m-%d'`_OXOwebsiteBackup.tar.gz +/bin/rsync --archive --backup --exclude "files/nextcloud*" --rsh=ssh backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH # Backup Gitea -/bin/rsync --archive --rsh=ssh googlemicro:~/ttt/*.zip ~/Backups/gitea/`date '+%Y-%m-%d'`_gitea.zip +/bin/rsync --archive --backup --rsh=ssh bkpgitea:~/ttt/* ~/Backups/gitea/ + +# Backup OXO Files +/bin/rsync --archive --backup --rsh=ssh oxo:~/public_html ~/Backups/OXOwebsite/ +tar cfz ~/Backups/OXOwebsite/`date '+%Y-%m-%d'`_OXOwebsiteBackup.tar.gz ~/Backups/OXOwebsite/public_html/ +rm -rf ~/Backups/OXOwebsite/public_html/ + +# Backup OXO DB +ssh oxo ./backupDB.sh +/bin/rsync --archive --backup --compress --rsh=ssh oxo:~/db/* ~/Backups/OXOwebsite/ +ssh oxo rm ./db/* # Delete old backups find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete find $CONTABO_BACKUP_PATH/keys -type f -name "*.*" -mtime +15 -delete find $CONTABO_BACKUP_PATH/files -type f -name "*.*" -mtime +35 -delete find $CONTABO_BACKUP_PATH/mail -type f -name "*.*" -mtime +20 -delete - find $CONTABO_BACKUP_PATH/ -type f -name "*.*" -mtime +120 -delete -find ~/Backups/OXOwebsite/ -type f -name "*.sql.gz" -mtime +15 -delete +find ~/Backups/OXOwebsite/ -type f -name "*.gz" -mtime +15 -delete +find ~/Backups/gitea/ -type f -name "*.zip" -mtime +15 -delete From 1be27fff1670c4ecfbeeb5719d876bc609b1af55 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 20 Feb 2022 19:04:12 -0300 Subject: [PATCH 64/65] fix: Neomutt now only opens after while Now it gives time for the gpg is already unlocked --- start-dashboard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-dashboard b/start-dashboard index b7fed0a..064205a 100755 --- a/start-dashboard +++ b/start-dashboard @@ -38,7 +38,7 @@ tmux rename-window -t dashboard:2 gomuks # 3 - NeoMutt tmux new-window -t dashboard sleep 1 -tmux send -t dashboard:3.0 $'neomutt\n' +tmux send -t dashboard:3.0 $'sleep 120 && neomutt\n' tmux rename-window -t dashboard:3 neomutt # 4 - Joplin From b926a7c2b4e0cd5afbe511fcc09b76239f4f4568 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sun, 20 Feb 2022 19:05:52 -0300 Subject: [PATCH 65/65] feat: add mbsync service every 5 minutes --- Services/mbsync.service | 7 +++++++ Services/mbsync.timer | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Services/mbsync.service create mode 100644 Services/mbsync.timer diff --git a/Services/mbsync.service b/Services/mbsync.service new file mode 100644 index 0000000..8aa13d6 --- /dev/null +++ b/Services/mbsync.service @@ -0,0 +1,7 @@ +[Unit] +Description=Mailbox synchronization service + +[Service] +Type=oneshot +ExecStart=/usr/bin/mbsync -Va +ExecStartPost=/home/bruno/dotfiles/mutt/notmuch-hook.sh diff --git a/Services/mbsync.timer b/Services/mbsync.timer new file mode 100644 index 0000000..82ebb83 --- /dev/null +++ b/Services/mbsync.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Mailbox synchronization timer + +[Timer] +OnBootSec=2m +OnUnitActiveSec=5m +Unit=mbsync.service + +[Install] +WantedBy=timers.target