capun 0.0.36 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capun/version.rb +1 -1
- data/lib/generators/capun/templates/backup.sh.erb +49 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebbfec60f7485585337c2a0f579ad4e8396369d1
|
4
|
+
data.tar.gz: 6c2a575d5f900e4e5b8388656b319cf86ef610af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856154d06b018eddf28f915c6bca6b44f1c119df653dff7bdb21bf61d90bb9376c19361a0da3e4872ca7e36d633347d5b378618179095c8349196c8669e8e765
|
7
|
+
data.tar.gz: edd8082e3d23a84ad81dec22c176da30eea2a08b8561cc414490039e9eb7809e8334609642b5e65df93f8f856b0e32c7c93db5c5a14927da301c43aec0a2b4b4
|
data/lib/capun/version.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
+
has_error=0
|
4
|
+
error_text="";
|
5
|
+
|
3
6
|
cd /home/<%= fetch(:user) %>/apps/<%= fetch(:application) %>/shared
|
4
7
|
curdate=$(date +"%m-%d-%y")
|
5
8
|
mkdir -p "backuping/version-$curdate"
|
@@ -16,28 +19,70 @@ DATA_BASE_TYPE="<%=fetch(:stage)%>.sql"
|
|
16
19
|
username=$(cat config/database.yml | grep username | sed s/username://g | xargs)
|
17
20
|
password=$(cat config/database.yml | grep password | sed s/password://g | xargs)
|
18
21
|
database=$(cat config/database.yml | grep database | sed s/database://g | xargs)
|
22
|
+
{
|
19
23
|
mysqldump --user="$username" --password="$password" $database > "backuping/version-$curdate/<%=fetch(:stage)%>.sql"
|
24
|
+
} || {
|
25
|
+
has_error=1
|
26
|
+
error_text="Mysql dump error"
|
27
|
+
}
|
28
|
+
fi
|
29
|
+
|
30
|
+
|
31
|
+
if [ "$adapter" = "postgresql" ]; then
|
32
|
+
DATA_BASE_TYPE="<%=fetch(:stage)%>.sql"
|
33
|
+
username=$(cat config/database.yml | grep username | sed s/username://g | xargs)
|
34
|
+
password=$(cat config/database.yml | grep password | sed s/password://g | xargs)
|
35
|
+
database=$(cat config/database.yml | grep database | sed s/database://g | xargs)
|
36
|
+
|
37
|
+
if grep "localhost:5432:$database:$username:$password" ~/.pgpass; then
|
38
|
+
echo "pg config exists"
|
39
|
+
else
|
40
|
+
echo "localhost:5432:$database:$username:$password" >> ~/.pgpass;
|
41
|
+
chmod 600 ~/.pgpass
|
42
|
+
fi
|
43
|
+
|
44
|
+
{
|
45
|
+
pg_dump -h localhost -U $username -d $database -f backuping/version-$curdate/<%=fetch(:stage)%>.sql
|
46
|
+
} || {
|
47
|
+
has_error=1
|
48
|
+
error_text="PG dump error"
|
49
|
+
}
|
20
50
|
fi
|
21
51
|
|
22
52
|
COUNTER=5
|
53
|
+
|
54
|
+
|
23
55
|
until [ $COUNTER -lt 1 ]; do
|
24
|
-
|
56
|
+
#{ #try
|
57
|
+
python drivesink.py upload "backuping" <%= fetch(:backupDestinationFolder) || "backups/firstdedic-server/" + fetch(:application) %> -c /home/kobe/.drivesink #>> log/backup.log 2>&1
|
58
|
+
#} || {
|
59
|
+
# has_error=1;
|
60
|
+
# error_text="Cannot upload files";
|
61
|
+
#}
|
25
62
|
if [ $? -eq 0 ]; then
|
26
63
|
COUNTER=0
|
27
64
|
else
|
28
|
-
COUNTER=$
|
65
|
+
COUNTER=$[$COUNTER -1]
|
29
66
|
fi
|
30
67
|
done
|
31
68
|
|
32
|
-
if [ $? -eq 0 ]; then
|
69
|
+
if ([ $? -eq 0 ] && [ "$has_error" == 0 ]); then
|
33
70
|
SIZE=$(du -sh backuping | awk '{print $1}')
|
34
71
|
curl -X POST -H 'Content-type: application/json' \
|
35
72
|
--data "{'attachments': [{'mrkdwn_in': ['text'],'text': 'Успешо создан бэкап для *<%= fetch(:application) %>*\n<% (fetch(:backupFolders) || []).each do |folder|%><%= "- " +folder + '\n' %><% end %>- $DATA_BASE_TYPE\nРазмер *$SIZE*','color': '#3AA3E3', 'title': 'Amazon Backup System'}]<%=", \'channel\': \'#{fetch(:slack_channel)}\' " if !fetch(:slack_channel).nil? %>}" \
|
36
73
|
<%= fetch(:slack_hook) %>
|
74
|
+
|
75
|
+
#telegram notification
|
76
|
+
curl -i -X GET ""https://api.telegram.org/bot<%= fetch(:backup_telegram_bot_hash) %>/sendMessage?chat_id=<%= fetch(:backup_telegram_chat_id) %>&text=✅ Бекап для <%= fetch(:application) %>"
|
77
|
+
|
37
78
|
else
|
38
79
|
curl -X POST -H 'Content-type: application/json' \
|
39
80
|
--data "{'attachments': [{'mrkdwn_in': ['text'],'text': 'Произошла ошибка при создании бэкапа для *<%= fetch(:application) %>','color': '#FF0000', 'title': 'Amazon Backup System'}]<%=", \'channel\': \'#{fetch(:slack_channel)}\' " if !fetch(:slack_channel).nil? %>}" \
|
40
81
|
<%= fetch(:slack_hook) %>
|
82
|
+
|
83
|
+
#telegram notification
|
84
|
+
curl -i -X GET "https://api.telegram.org/bot<%= fetch(:backup_telegram_bot_hash) %>/sendMessage?chat_id=<%= fetch(:backup_telegram_chat_id) %>&text=🚫 Бекап для <%= fetch(:application) %> \[Error: $error_text\]"
|
85
|
+
|
41
86
|
fi
|
42
87
|
|
43
|
-
rm -rf backuping
|
88
|
+
sudo rm -rf backuping
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zamylin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,8 +164,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.6.12
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Opinionated Rails deployment solution with CAPistrano, Unicorn and Nginx.
|
171
171
|
test_files: []
|
172
|
+
has_rdoc:
|