Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- fecha=$(date +%H-%M-%S)
- server=192.168.0.209
- if [ "$1" == "ssh-key" ]; then
- ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
- ssh-copy-id -i $HOME/.ssh/id_rsa.pub backupsrv@$server
- exit 0
- elif [ "$1" == "gpg-key" ]; then
- gpg --batch --gen-key <<EOF
- %no-protection
- Key-Type: RSA
- Key-Length: 2048
- Subkey-Type: RSA
- Subkey-Length: 2048
- Name-Real: Your Name
- Name-Email: educacionit@$HOSTNAME
- Expire-Date: 0
- %commit
- EOF
- gpg --export -a "educacionit@$HOSTNAME" > educacionit.$HOSTNAME.asc
- scp educacionit.$HOSTNAME.asc backupsrv@$server:~/
- ssh backupsrv@$server gpg --import educacionit.$HOSTNAME.asc
- exit 0
- fi
- mysqldump --all-databases > /var/backups/${fecha}_all-db.sql
- gpg --detach-sign /var/backups/${fecha}_all-db.sql
- # Crear directorio en el remoto.
- ssh backupsrv@$server mkdir -p /home/backupsrv/$HOSNTNAME
- rsync -a -v -e "ssh -i ~/.ssh/id_rsa" /var/backups/ backupsrv@${server}:~/$HOSTNAME
Advertisement
Comments
-
- I fixed your bash code you forgot to put double Quotes
- #!/bin/bash
- fecha=$(date +%H-%M-%S)
- server=192.168.0.209
- if [ "$1" == "ssh-key" ]; then
- ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
- ssh-copy-id -i "$HOME/.ssh/id_rsa.pub backupsrv@$server"
- exit 0
- elif [ "$1" == "gpg-key" ]; then
- gpg --batch --gen-key <<EOF
- %no-protection
- Key-Type: RSA
- Key-Length: 2048
- Subkey-Type: RSA
- Subkey-Length: 2048
- Name-Real: Your Name
- Name-Email: educacionit@$HOSTNAME
- Expire-Date: 0
- %commit
- EOF
- gpg --export -a "educacionit@$HOSTNAME" > "educacionit.$HOSTNAME.asc"
- scp educacionit."$HOSTNAME".asc backupsrv@$server:~/
- ssh backupsrv@$server gpg --import educacionit."$HOSTNAME".asc
- exit 0
- fi
- mysqldump --all-databases > /var/backups/"${fecha}"_all-db.sql
- gpg --detach-sign /var/backups/"${fecha}"_all-db.sql
- # Crear directorio en el remoto.
- ssh backupsrv@$server mkdir -p /home/backupsrv/"$HOSNTNAME"
- rsync -a -v -e "ssh -i ~/.ssh/id_rsa" /var/backups/ backupsrv@${server}:~/"$HOSTNAME"
Add Comment
Please, Sign In to add comment
Advertisement