Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Declaring variables:
- pathmount="mnt/remote"
- pathbackup="samba/storage/backups"
- #Functions
- runbackup(){
- local computer="$1" pathcomputer="$2"
- #Creates dirs if not exist
- mkdir -p "/$pathbackup/$computer/"{0,1,2} || return
- mkdir -p "/$pathmount/$computer" || return
- #Rotating
- rm -fr "/$pathbackup/$computer/2"
- mv "/$pathbackup/$computer/1" "/$pathbackup/$computer/2"
- cp -la "/$pathbackup/$computer/0" "/$pathbackup/$computer/1"
- #Mounts and rsyncs
- sudo mount -t cifs "//$computer/c$" -o username=backupadmin,password=pwlol "/$pathmount/$computer" && \
- sudo rsync -avP "/$pathmount/$computer/$pathcomputer/*" "/$pathbackup/$computer/0/"
- sudo umount "/$pathmount/$computer"
- }
- #RUNNING
- ## example
- #runbackup computer-IP "path/client"
- runbackup 10.247.180.232 "Documents\ and\ Settings/User"
- #Getting errors:
- #sending incremental file list
- #rsync: change_dir "/mnt/remote/10.247.180.232/Documents\ and\ Settings/User" failed: Invalid argument (22)
- #
- #sent 12 bytes received 12 bytes 48.00 bytes/sec
- #total size is 0 speedup is 0.00
- #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