24 lines
799 B
Bash
24 lines
799 B
Bash
#!/bin/bash
|
|
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server ip : ${RESET}"
|
|
read -s receiving_ip
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server user : ${RESET}"
|
|
read -s receiving_user
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server port : ${RESET}"
|
|
read -s receiving_port
|
|
|
|
ssh-keygen
|
|
ssh-copy-id -p ${receiving_port} ${receiving_user}@${receiving_ip}
|
|
|
|
install_pkg cron
|
|
|
|
cp ../assets/backup.sh ~/backup.sh
|
|
chmod +x ~/backup.sh
|
|
|
|
sed -i "s/^receiving_ip=.*/receiving_ip=$receiving_ip/" ~/backup.sh
|
|
sed -i "s/^receiving_user=.*/receiving_ip=$receiving_user/" ~/backup.sh
|
|
sed -i "s/^receiving_port=.*/receiving_ip=$receiving_port/" ~/backup.sh
|
|
|
|
cronjob="0 2 * * * ~/backup.sh"
|
|
|
|
(crontab -l | grep -F ~/backup.sh) && echo "Cron job already exists" || (crontab -l; echo "$cronjob") | crontab - |