T
T
Twelfth Doctor2017-08-09 11:43:42
linux
Twelfth Doctor, 2017-08-09 11:43:42

How to backup users?

Hello. How can I backup the home directories of all users (backup files in a tar archive) whose login starts with u to the user folder (/home/u%name%/backup) and dump all databases that start with u%name% into this same folder?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-08-09
@verdex

Get a list of users -
ls -1d /home/u*
Make a script that will perform the actions you need for each received name, and backup the necessary data and run it through for example
ls -1d /home/u* | xargs backup.sh

P
pfg21, 2017-08-09
@pfg21

script, it contains:
generation of user database dumps
generation of a list of user directory names into a temporary file ( + database dump names must also be present in the list).
launching tar with the additional option --files-from *temporary file* (reading the list of the archived to take from the file)
option 2: something like

tar cf backup.tar --anchored --exclude='u*'  /home /path/dump_bd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question