|
|
- sqlBackUp<-function(dbfile=file,conn=dta,bu.dir=NULL){
- if(sqlTables(conn) %>% filter(TABLE_NAME == "UMID") %>% nrow > 0){bu.dir<-"BU_UM"}
- if(sqlTables(conn) %>% filter(TABLE_NAME == "OVID") %>% nrow > 0){bu.dir<-"BU_OVARIO"}
-
- db=strsplit(dbfile, "/")[[1]]%>% tail(n=1)
- bu_path<-gsub(db,bu.dir,dbfile)
- if (!dir.exists(bu_path)){
- dir.create(bu_path)
- print(paste0("Back Up directory ", bu_path, " created"))
- }
- cp_bu<-paste0(bu_path, "/", format(Sys.time(), format="%Y%m%d"),"-",db)
- file.copy(dbfile, cp_bu)
- }
|