Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Declaring variables:
  4. pathmount="mnt/remote"
  5. pathbackup="samba/storage/backups"
  6.  
  7. #Functions
  8.  
  9. runbackup(){
  10. local computer="$1" pathcomputer="$2"
  11. #Creates dirs if not exist
  12. mkdir -p "/$pathbackup/$computer/"{0,1,2} || return
  13. mkdir -p "/$pathmount/$computer" || return
  14. #Rotating
  15. rm -fr "/$pathbackup/$computer/2"
  16. mv "/$pathbackup/$computer/1" "/$pathbackup/$computer/2"
  17. cp -la "/$pathbackup/$computer/0" "/$pathbackup/$computer/1"
  18.  
  19. #Mounts and rsyncs
  20. sudo mount -t cifs "//$computer/c$" -o username=backupadmin,password=pwlol "/$pathmount/$computer" && \
  21. sudo rsync -avP "/$pathmount/$computer/$pathcomputer/*" "/$pathbackup/$computer/0/"
  22. sudo umount "/$pathmount/$computer"
  23. }
  24.  
  25.  
  26. #RUNNING
  27. ## example
  28. #runbackup computer-IP "path/client"
  29.  
  30.  
  31. runbackup 10.247.180.232 "Documents\ and\ Settings/User"
  32.  
  33.  
  34. #Getting errors:
  35. #sending incremental file list
  36. #rsync: change_dir "/mnt/remote/10.247.180.232/Documents\ and\ Settings/User" failed: Invalid argument (22)
  37. #
  38. #sent 12 bytes  received 12 bytes  48.00 bytes/sec
  39. #total size is 0  speedup is 0.00
  40. #rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1060) #[sender=3.0.7]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement