how to automatically backup and restore all files except home folder in linux
- User
how to automatically backup and restore all files except home folder in linux
- Assistant
To automatically backup and restore all files except the home folder in Linux, you can use the rsync command:
-
Backup:
- Open a terminal.
- Run the following command to create a backup of all files except the home folder:
Replace "/path/to/backup/folder" with the actual destination path where you want to store the backup.rsync -av --exclude='/home' / /path/to/backup/folder
-
Restore:
- Open a terminal.
- Run the following command to restore the previously created backup (replace "/path/to/backup/folder" with the actual backup folder location):
This command will restore all the files from the backup to their original locations, excluding the home folder.rsync -av /path/to/backup/folder/ /
Be cautious when using the restore command, as it will overwrite any existing files with the same names.
-
- User
a bash script to automatically backup and restore all files except home folder to a given destination in linux at a given data point everyday
- Assistant
To create a bash script that automatically backs up and restores all files except the home folder to a given destination in Linux at a specific date and time every day, follow these steps:
-
Create a new file called
backup_script.sh(or any name you prefer) using a text editor. -
Add the following content to the script:
#!/bin/bash # Backup rsync -av --exclude='/home' / /path/to/backup/folder # Restore rsync -av /path/to/backup/folder/ /Replace "/path/to/backup/folder" with the actual destination path where you want to store the backup.
-
Save the script and exit the text editor.
-
Open the terminal and make the script executable by running the following command:
chmod +x backup_script.sh
-