forked from copyhacker/backup_fu
-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
148 lines (84 loc) · 3.85 KB
/
README
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
BackupFu
========
The backup_fu plugin makes it redonkulously easy to:
A) dump your database and/or static files to tar/gzipped or zipped archives
B) upload these archives using external provider (currently AWS S3 and FTP server are supported)
Allows restore of PostgreSQL databases.
Installation
============
Install the plugin with:
script/plugin install git://github.com/ghandal/backup_fu.git
Configuration
=============
Run the following to copy over the example backup_fu.yml config file:
rake backup_fu:setup
This copies the example config file to: config/backup_fu.yml.
Usage
=====
For the list of available rake tasks:
rake -T backup_fu
Backing up your database:
rake backup
Dumping your database:
rake backup_fu:dump
Backing up your static files:
rake backup_fu:static:backup
Backing up both your database + static files:
rake backup_fu:all
Restoring from FTP:
rake backup_fu:restore BACKUP_FILE=myapp_1999-12-31_12345679_db.tar.gz
Advanced Configuration
======================
See vendor/plugins/backup_fu/config/backup_fu.yml.advanced_example for
the list of advanced configuration options.
Advanced options include:
* specify static path(s) that should be backed up -- i.e. backup your entire 'public/static' directory
* change default dump path from RAILS_ROOT/tmp/backup to whatever
* specify fully-qualified 'mysqldump' path
* disable compression of database dump
* choose between zip or tar/gzip compression
* enable 'nice' with level specification to prevent backup_fu from bogarting your server
Cronjob Installation
====================
Here are some cron job examples.
# Backup just the database everyday at 1am
0 1 * * * cd /apps/foo/current; RAILS_ENV=production rake backup > /dev/null
# Backup db + static @ 2am every 3 days, log the results to ~/backup.log (verbosity should be turned on if logging results)
0 2 1-31/3 * * cd /u/apps/shanti.railsblog/current; RAILS_ENV=production rake backup_fu:all >> ~/backup.log
Debugging
=========
--- Enabling Verbosity
If you are experiencing any difficulties, the first thing you should do is enable verbosity by
dropping this into config/backup_fu.yml:
verbose: true
--- Mysqldump Issues
If your 'mysqldump' command is not in your path, you will need to specify it explicitly.
To see if mysqldump is in your path, execute:
which mysqldump
If you see output like "/usr/bin/which: no mysqldump in (...)" then you will need to specify the path manually.
Use 'locate mysqldump' or a similar tool to find the full path to your mysqldump utility.
Place an entry like the following in your config/backup_fu.yml file:
mysqldump_path: /usr/local/mysql-standard-5.0.27-linux-i686/bin/mysqldump
--- Database Connection Issues
If you are seeing an error when running 'rake backup' like:
mysqldump: Got error: 2002: Can't connect to local MySQL server ...
Make sure you are specifying the RAILS_ENV for the target environment. i.e. for production:
RAILS_ENV=production rake backup
or
rake backup RAILS_ENV=production
--- Connection reset by peer
When backing up, if you receive an error like:
rake aborted!
Connection reset by peer
Chances are this is because your backup is huuge. There is currently no great solution for
this problem.
On some systems, I have backed up 4GB+ files without a hitch. On other machines, an 80mb
backup was choking on the S3 upload. After 3 attempts it went through.
Patching in some kind of email notification system on failure would probably be nice.
Patches welcome =)
--- Tiny Static file .tar.gz Archive (static files not actually getting archived)
This may result if you are using a symlink for your static dir, such as:
public/static -> /shared/apps/foo/static
The solution to this is to specify the absolute static path in config/backup_fu.yml:
static_paths: /shared/apps/foo/static
Copyright (c) 2009, released under the MIT license