File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99db_pass = "db_pass" # password of the user to access database
1010db_to_backup = "app_production" # name of the database to backup
1111
12- ##########
13- # Misc
14- ##########
12+ ###################
13+ # Naming & paths
14+ ###################
1515now = Time . now
1616
1717backup_name = "#{ now . to_s . gsub ( ' ' , '_' ) } .pg_dump" # name of the created backup file
2020oldest_backup_date = ( now . to_datetime << 1 ) . to_time # More than a month old
2121
2222#############################
23- # Script
23+ # Backup & upload to dropbox
2424#############################
2525print "Backing up #{ db_to_backup } \n "
2626system (
3636)
3737
3838print "Uploading #{ backup_file_path } to #{ backup_folder } /#{ backup_name } (~#{ ( File . size ( backup_file_path ) / ( 1024 * 1024 ) ) . round ( 2 ) } MB)\n "
39- # Upload to dropbox
4039client = Dropbox ::Client . new ( dropbox_access_token )
4140client . upload "#{ backup_folder } /#{ backup_name } " , File . read ( backup_file_path )
4241
Original file line number Diff line number Diff 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+
8791Issues 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+ ```
You can’t perform that action at this time.
0 commit comments