@name 备份数据库 @param args['path'] 数据库路径 @return bool
(self,args)
| 107 | |
| 108 | |
| 109 | def ToBackup(self,args): |
| 110 | """ |
| 111 | @name 备份数据库 |
| 112 | @param args['path'] 数据库路径 |
| 113 | @return bool |
| 114 | """ |
| 115 | path = args.path |
| 116 | if not os.path.exists(path): |
| 117 | return public.returnMsg(False,'数据库不存在.') |
| 118 | |
| 119 | data = self.get_database_list() |
| 120 | if not path in data: |
| 121 | return public.returnMsg(False,'数据库不存在.') |
| 122 | |
| 123 | fileName = '{}_{}'.format(time.strftime('%Y%m%d_%H%M%S',time.localtime()),os.path.basename(path)) |
| 124 | backup_path = '{}/database/sqlite/{}'.format(session['config']['backup_path'],public.md5(path)) |
| 125 | if not os.path.exists(backup_path): |
| 126 | os.makedirs(backup_path) |
| 127 | |
| 128 | backup_file = '{}/{}'.format(backup_path,fileName) |
| 129 | shutil.copy(path,backup_file) |
| 130 | if os.path.exists(backup_file): |
| 131 | return public.returnMsg(True,'备份成功.') |
| 132 | return public.returnMsg(False,'备份失败.') |
| 133 | |
| 134 | |
| 135 | def DelBackup(self,args): |