-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-gdrive-backup-script.sh
66 lines (57 loc) · 1.54 KB
/
install-gdrive-backup-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
install_gdrive_binary()
{
if [ -f "/sbin/gdrive" ]; then
echo "Looks like /sbin/gdrive already exists. Aborting installation!"
exit 1
else
wget -qO /sbin/gdrive https://github.com/gdrive-org/gdrive/releases/download/2.1.0/gdrive-linux-x64
chmod +x /sbin/gdrive
fi
}
dry_run_gdrive()
{
echo "Test running first Gdrive transaction
"
/sbin/gdrive list
echo "
"
}
configure_sync_folder()
{
folder_id=`/sbin/gdrive mkdir $(hostname)-backups | awk '{print $2}'`
echo "Created Gdrive folder `hostname`-backups with ID $folder_id. The same would be used in backup script - /gdrive-backups/backup.sh"
}
install_backup_script()
{
mkdir /gdrive-backups/
wget -qO /gdrive-backups/backup.sh http://raw.githubusercontent.com/ashithwilson/server-side/master/gdrive-backup.sh
sed -i "s|REPLACE_WITH_GDRIVE_FOLDER_ID|$folder_id|g" /gdrive-backups/backup.sh
chmod +x /gdrive-backups/backup.sh
}
print_summary()
{
touch /gdrive-backups/mysql_backup_list.txt
touch /gdrive-backups/backup-list.txt
echo "
============
============
Backup script is installed at /gdrive-backups/backup.sh
Check gdrive details using command 'gdrive help'
Website files - backup list : /gdrive-backups/backup-list.txt
Db - backup list: /gdrive-backups/backup-list.txt
============
** Do not forget to set up daily/weekly cron for backups **
"
}
echo ""
read -p "Are you sure to install gdrive backups? [Y/n]: " opt
if [ "$opt" == "Y" ] || [ "$opt" == "y" ]; then
install_gdrive_binary
dry_run_gdrive
configure_sync_folder
install_backup_script
print_summary
else
echo "Aborting!!!"
fi