24 lines
735 B
Bash
24 lines
735 B
Bash
#!/bin/bash
|
|
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server ip : ${RESET}"
|
|
read receiving_ip
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server user : ${RESET}"
|
|
read receiving_user
|
|
echo -e "${PURPLE}${BOLD}Enter the receiving server port : ${RESET}"
|
|
read 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_user=$receiving_user/" ~/backup.sh
|
|
sed -i "s/^receiving_port=.*/receiving_port=$receiving_port/" ~/backup.sh
|
|
|
|
cronjob="0 2 * * * ~/backup.sh"
|
|
|
|
( crontab -l 2>/dev/null; echo "$cronjob" ) | crontab - |