Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
e6c3c681
Commit
e6c3c681
authored
Oct 05, 2011
by
egarcia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup now sends sucess + error emails with logs
parent
ff534331
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
Rakefile
backup/Rakefile
+24
-13
smtp.yml.sample
backup/smtp.yml.sample
+2
-1
No files found.
backup/Rakefile
View file @
e6c3c681
...
...
@@ -73,8 +73,6 @@ f = File.open('smtp.yml')
SMTP
=
YAML
::
load
(
f
)
f
.
close
puts
SMTP
.
inspect
# =========== END OF CUSTOMIZABLE SETTINGS =============
# Server urls. Used for obtaining the list of svn repositories
...
...
@@ -89,14 +87,18 @@ REMOTE_REPOSITORY_URLS = {
'production'
=>
'http://svn.ohwr.org'
}
def
title
(
text
,
level
=
0
)
puts
log
text
,
level
puts
end
@log_io
=
StringIO
.
new
()
def
log
(
message
,
level
=
0
)
puts
"
#{
'=='
*
level
}
>
#{
message
}
"
text
=
"
#{
'=='
*
level
}
>
#{
message
}
"
@log_io
.
puts
text
puts
text
end
def
title
(
text
,
level
=
0
)
log
""
log
text
,
level
log
""
end
def
remote_repository_url
(
repository
)
...
...
@@ -125,8 +127,9 @@ end
def
send_email
(
subject
,
body
)
Pony
.
mail
(
:to
=>
[
'to'
],
:subject
=>
"Error in OHWR backup:
#{
subject
}
"
,
:to
=>
SMTP
[
'to'
],
:cc
=>
SMTP
[
'cc'
],
:subject
=>
subject
,
:body
=>
body
,
:via
=>
:smtp
,
:attachments
=>
[],
...
...
@@ -147,13 +150,15 @@ def shell(command)
err
=
StringIO
.
new
status
=
Open4
::
popen4
(
command
)
do
|
pid
,
stdin
,
stdout
,
stderr
|
@log_io
<<
stdout
.
read
.
strip
err
<<
stderr
.
read
.
strip
end
if
status
.
exitstatus
==
0
then
log
"
#{
command
}
- ok"
else
send_email
(
"(
#{
status
.
exitstatus
}
) -
#{
command
}
"
,
err
.
string
)
send_email
(
"ERROR in OHWR backup (
#{
status
.
exitstatus
}
) -
#{
command
}
"
,
"
#{
err
.
string
}
\n\n
log:
\n
#{
@log_io
.
string
}
"
)
title
(
"ERROR"
)
fail
(
"Command failed(
#{
status
.
exitstatus
}
) -
#{
command
}
:
\n
#{
err
.
string
}
"
)
end
end
...
...
@@ -207,7 +212,7 @@ namespace :backup do
task
:prepare_folders
do
title
"Preparing local folders"
[
LOCAL_REPOSITORY_PATH
,
LOCAL_GIT_PATH
,
LOCAL_DB_PATH
,
LOCAL_FILES_PATH
,
File
.
join
(
LOCAL_SYMPA_PATH
,
'arc'
),
File
.
join
(
LOCAL_SYMPA_PATH
,
'list_data'
)].
each
do
|
path
|
shell
"mkdir
#{
path
}
"
shell
"mkdir
-p
#{
path
}
"
end
end
...
...
@@ -261,7 +266,13 @@ namespace :backup do
rdiff_get
'/home/sympa/list_data'
,
File
.
join
(
LOCAL_SYMPA_PATH
,
'list_data'
)
end
desc
"Sends an email saying - everything went ok"
task
:send_ok_email
do
title
"Sending OK email"
send_email
(
"OHWR backup sucessful"
,
"complete log:
\n
#{
@log_io
.
string
}
"
)
end
desc
"Implements all backup (svn+db+files+sympa)"
task
:all
=>
[
:svn
,
:git
,
:db
,
:files
,
:sympa
]
task
:all
=>
[
:svn
,
:git
,
:db
,
:files
,
:sympa
,
:send_ok_email
]
end
backup/smtp.yml.sample
View file @
e6c3c681
to: 'egarcia@splendeo.es'
to: 'support@splendeo.es'
cc: 'fjuan@splendeo.es'
server: 'smtp.gmail.com'
port: '587'
user_name: 'contact@splendeo.es'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment