Re: Archiving content of a directory on a DVD-R.
On Mon, Nov 12, 2018 at 01:13:14PM -0800, peter@easthope.ca wrote:
> How are multiple commands defined in one file? Then invoke?
> sudo backup1
> sudo backup2
> sudo backup3
Just put all the commands in one script, for example:
#!/bin/sh
backup1 &&
backup2 &&
backup3
Then run "sudo /the/backupscript". If it's in a directory in your PATH,
you can simply do "sudo backupscript".
Of course, your example is so entirely obfuscated and genericized that
it's meaningless. You can't even demonstrate anything with it.
Here's the backup script I use at home, with only one piece of information
hidden. It's not elegant. It's simply what I've got.
It is named /usr/local/bin/backup. When I want to run it, I type
"sudo backup".
#!/bin/bash
cd /backup || exit
today=$(date +%Y%m%d)
if [ -e /hd/.hd ]; then
( cd / && rsync -av --delete etc home usr/local /hd/titan/ )
( cd /stuff && rsync -av --delete * /hd/ )
else
echo "/hd not mounted"
fi
( cd /etc && find . -print0 |
cpio -o -0 | gzip > "/backup/compress/backup.$HOSTNAME.etc.$today" )
( export RSYNC_RSH='ssh -p [REDACTED]';
cd remote && rsync -av --delete root@remote.wooledge.org:{/etc,/var/moin} . )
( cd remote && find . -print0 |
cpio -o -0 | gzip > "/backup/compress/backup.remote.$today" )
( cd /home && find . \( -type d -name .cache \) -prune -o -print0 |
cpio -o -0 | gzip > "/backup/compress/backup.$HOSTNAME.home.$today" )
find compress -type f -mtime +4 -delete
( cd compress && mkisofs -o ../image . )
ls -ld image
read -p "Write to DVD? [y] " yn
case $yn in ''|[Yy]|[Yy]es) : ;; *) exit ;; esac
cdrecord -v image
Reply to: