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

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