Skip to content

Commit 8cf602a

Browse files
committed
Note about MySQL support
1 parent 48c8942 commit 8cf602a

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

backup.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
db_pass = "db_pass" # password of the user to access database
1010
db_to_backup = "app_production" # name of the database to backup
1111

12-
##########
13-
# Misc
14-
##########
12+
###################
13+
# Naming & paths
14+
###################
1515
now = Time.now
1616

1717
backup_name = "#{now.to_s.gsub(' ', '_')}.pg_dump" # name of the created backup file
@@ -20,7 +20,7 @@
2020
oldest_backup_date = (now.to_datetime << 1).to_time # More than a month old
2121

2222
#############################
23-
# Script
23+
# Backup & upload to dropbox
2424
#############################
2525
print "Backing up #{db_to_backup}\n"
2626
system(
@@ -36,7 +36,6 @@
3636
)
3737

3838
print "Uploading #{backup_file_path} to #{backup_folder}/#{backup_name} (~#{(File.size(backup_file_path) / (1024 * 1024)).round(2)} MB)\n"
39-
# Upload to dropbox
4039
client = Dropbox::Client.new(dropbox_access_token)
4140
client.upload "#{backup_folder}/#{backup_name}", File.read(backup_file_path)
4241

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,22 @@ Youre database is now being backed up in your dropbox and can be restored with:
8484
$ pg_restore -C -d database_name 2016-02-24T05_12_01-05_00.pg_dump.tar
8585
```
8686

87+
```
88+
$ pg_restore -C -d database_name 2016-02-24T05_12_01-05_00.pg_dump.tar
89+
```
90+
8791
Issues and pull requests to improve documentation or code are welcome.
92+
93+
# MySQL Support
94+
95+
If creating a dump for a MySQL database. You'll need to replace the `system` call in your server for the appropiate adapter:
96+
```
97+
system(
98+
"mysqldump " +
99+
"-u #{db_user} " + # user
100+
"-p #{db_pass} " + # password
101+
"-h 127.0.0.1 " + # host
102+
db_to_backup + # database
103+
" > #{backup_file_path}"
104+
)
105+
```

0 commit comments

Comments
 (0)