[PLUG] BASH script make a backup...

King Beowulf kingbeowulf at gmail.com
Sat Apr 4 21:48:47 UTC 2020


On 4/4/20 1:03 PM, michael at robinson-west.com wrote:
> Of course, leave off the $ when defining a variable in Bash!
> 
> I'm using the following tar invocation:
> 
> tar --one-file-system -cvjf foo.tar.bz2 foo/
> 
> Is there a way to tar up symbolic links as links?
> 
> What about permissions?

#!/bin/bash
dump_dir="/home/Shared/backup/"
...
mkdir -p $dump_dir
# -p creates parent directories if needed
...
tar --one-file-system -cpvjf foo.tar.bz2 foo/
...

Omitting -h should backup any symlinks and not just the files they point
to. Just remember to add -h when you extract to restore the symlinks.
-p preserves perms (default if superuser)
--keep-directory-symlink if you have symlinks to directories.
(see man tar)

> 
> Should I run this as root in runlevel 1?
> 

Why?  running as user is fine or use su or sudo.  Your user just needs
access to the source and target directories.

> 
> Instead of starting over, could I uninstall X Windows from the existing system in console mode for troubleshooting?
> I think with X gone that network manager will go too which may be the source of my networking problems.

if you don't need X apps etc, and just use the console, dump it.
Removing X won't remove usually Network Manager as NM has a CLI
component. Of course, that depends on the dependency list for NM and X
for your distro package manager.

-Ed

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20200404/06ac4c6e/attachment.asc>


More information about the PLUG mailing list