mirror of
				https://github.com/skishore/makemeahanzi.git
				synced 2025-11-01 03:45:51 +08:00 
			
		
		
		
	Add methods to backup and wipe server
This commit is contained in:
		
							
								
								
									
										20
									
								
								server/backup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								server/backup.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| var child_process = Npm.require('child_process'); | ||||
| var path = Npm.require('path'); | ||||
|  | ||||
| function get_backup_path() { | ||||
|   return path.join(process.env.PWD, 'server', 'backup'); | ||||
| } | ||||
|  | ||||
| Meteor.methods({ | ||||
|   backup: function() { | ||||
|     var path = get_backup_path(); | ||||
|     child_process.spawn('mongodump', ['--port', '3001', '--out', path]); | ||||
|   }, | ||||
|   restore: function() { | ||||
|     var path = get_backup_path(); | ||||
|     child_process.spawn('mongorestore', ['--port', '3001', '--drop', path]); | ||||
|   }, | ||||
|   wipe: function() { | ||||
|     base.collection.remove({}); | ||||
|   }, | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user
	 Shaunak Kishore
					Shaunak Kishore