Funciones para la interacción de bases de datos del grupo CIT.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
530 B

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)
}