You are not logged in.
https://wiki.archlinux.org/index.php/Fu … ith_a_list
Is there a way to "<<" the "backup.lst" file inside "backup.sh"?
Last edited by DSpider (2012-07-21 11:34:31)
I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).
Offline
This should work, but I feel is "wrong".
#!/bin/bash
exec 5< <(
cat <<EOF
here document
EOF
)
sudo sh -c "cat /proc/$$/fd/5"
Is there any way to pass a file descriptor through sudo?
Offline
From rsync(1):
--exclude-from=FILE
This option is related to the --exclude option, but it specifies
a FILE that contains exclude patterns (one per line). Blank
lines in the file and lines starting with ';' or '#' are
ignored. If FILE is -, the list will be read from standard
input. (emphasis mine)
So something like this might work (untested):
sudo sh -c "
rsync -av --delete-excluded --exclude-from=- / $1;
date > $1/BACKUP
" <<EOF
...
EOF
I wouldn't write it like that personally; I'd at least leave off the sudo and run the whole thing with sudo if I needed permissions. Actually I'd do a lot of things differently than that page. But that's neither here nor there.
Last edited by Trent (2012-07-20 15:30:03)
Offline
How would you do it differently?
Because I also think it's too complicated.
Last edited by DSpider (2012-07-20 16:34:38)
I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).
Offline
#!/bin/sh
rsync -av /* /media/Backup/bak --exclude-from=- <<-"EOF"
# Exclude list:
- /dev/*
- /proc/*
- /sys/*
- /tmp/*
- /run/*
- /mnt/*
- /media/*
- /lost+found
- /home/*/.gvfs
EOF
This works.
Couldn't manage to place the list at the top of the rsync line, so I revised my approach a bit and eventually came up with this script:
#!/bin/sh
START=$(date +%s)
rsync -av /* /media/Backup/bak --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs}
FINISH=$(date +%s)
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"
touch /media/Backup/bak/"Backup from $(date '+%A, %d %B %Y, %T')"
It's simple, it's elegant and makes a lot more sense. I will replace "/media/Backup/bak" with "$1" and update the wiki.
Thank you, both.
Last edited by DSpider (2012-07-21 11:36:07)
I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).
Offline
I was going to describe how I might do things differently, but you've found a pretty reasonable solution and I don't see a need to improve on it.
I don't do full-system backups myself.
Offline