Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: What kind of backups are available?

  1. #1

    Default What kind of backups are available?

    Would it be possible for me to take a sort of profile/user backup? I may need to format my HD and reinstall OpenSUSE but I don't want to have configure and install everything again. Can all that stuff be backed up and restored onto a fresh system?

    Thanks

  2. #2
    Join Date
    Sep 2012
    Location
    Canada
    Posts
    112

    Default Re: What kind of backups are available?

    Hi Astralogic,

    If you /home directory is in a dedicated partition, you can install openSUSE without formatting it (but personnaly I would make a backup just in case). But if you need to format all your hard drive, you can easily make a backup of the current user profile using any archive and backup tool. Using good old tar:

    Code:
    /$ tar --one-file-system -cWf backupFilePath "$HOME" --exclude="$HOME/.cache"
    Where backupFilePath is where you want the TAR archive to be created. I don't think you want to backup your applications' cache, this why the folder .cache in your home directory is excluded. In order to this command line to succeed, you should run it from the root of your file-system (/) otherwise tar will not be able to check files have been successfully backed up.
    Kalten

  3. #3
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,497

    Default Re: What kind of backups are available?

    Your /home partition has all your user settings but, if you have made changes to system files, they are likely to be in /etc and, if you are using mysql, you should back it up with mysqldump - I simply back up the relevant files to /home and then they are backed up when I back up /home.

  4. #4

    Default Re: What kind of backups are available?

    Quote Originally Posted by kalten View Post
    Hi Astralogic,

    If you /home directory is in a dedicated partition, you can install openSUSE without formatting it (but personnaly I would make a backup just in case). But if you need to format all your hard drive, you can easily make a backup of the current user profile using any archive and backup tool. Using good old tar:

    Code:
    /$ tar --one-file-system -cWf backupFilePath "$HOME" --exclude="$HOME/.cache"
    Where backupFilePath is where you want the TAR archive to be created. I don't think you want to backup your applications' cache, this why the folder .cache in your home directory is excluded. In order to this command line to succeed, you should run it from the root of your file-system (/) otherwise tar will not be able to check files have been successfully backed up.
    Will this backup include the shortcuts to new programs in the K menu? I don''t mind redoing the odd system setting or two.

    Also what would be the command to restore the backup?

  5. #5

    Default Re: What kind of backups are available?

    Quote Originally Posted by Astralogic View Post
    Will this backup include the shortcuts to new programs in the K menu? I don''t mind redoing the odd system setting or two.
    Do you mean manually created shortcuts?
    Those are stored in /home, yes. (~/.local/share/applications/)

    The standard shortcuts get created when you install the corresponding applications, so no need to backup those.

  6. #6
    Join Date
    Sep 2012
    Location
    Canada
    Posts
    112

    Default Re: What kind of backups are available?

    Quote Originally Posted by Astralogic
    Will this backup include the shortcuts to new programs in the K menu? I don''t mind redoing the odd system setting or two.
    As wolfi323 said, a backup a your home directory will contain the application shortcuts created manually because they are stored in your home directory.

    Quote Originally Posted by Astralogic
    Also what would be the command to restore the backup?
    The command line to restore the backup would be something like:

    Code:
    /# tar -xf backupFilePath
    You may need to change the owner of the restored home directory using chown if your new user doesn't have the same uid than the old one.
    Kalten

  7. #7

    Default Re: What kind of backups are available?

    Thanks for the info. I just found KBackup, it's basically exactly what you describe here, files being backed up with TAR except it takes care of all the commands.

    I've looked up the chown command, it seems simple but let me see if I have it right. My login name is 'calvin' I just type "chown calvin "$HOME" right?.

    But what if after formatting and reinstalling I use the same name, I wouldn't need to change the owner correct? Because they'd be the same.

  8. #8

    Default Re: What kind of backups are available?

    Quote Originally Posted by Astralogic View Post
    I've looked up the chown command, it seems simple but let me see if I have it right. My login name is 'calvin' I just type "chown calvin "$HOME" right?.
    Nearly.
    Add the -R option, to recursively change all files in all subdirectories as well, and probably you would have to do it as root:
    Code:
    sudo chown -R calvin /home/calvin
    But what if after formatting and reinstalling I use the same name, I wouldn't need to change the owner correct? Because they'd be the same.
    The owner is stored as a number internally, so the name doesn't actually matter.
    If there's only one user in either case, the id _should_ stay the same.

    The user name DOES matter for the _name_ of the home directory of course.
    So if you use "calvin2" as user name on the new install f.e., your home directory would be named /home/calvin2 instead of /home/calvin.
    You maybe have to consider this when restoring the backup.

  9. #9

    Default Re: What kind of backups are available?

    Quote Originally Posted by kalten View Post
    The command line to restore the backup would be something like:

    Code:
    /# tar -xf backupFilePath
    I just realized that I''m not sure what the file path should be. The home folder that gets backed up isn't the actual folder called home is it? It's the folder with my user name which is inside the home folder. So it should be restored to /home. Is that right?

  10. #10
    Join Date
    Sep 2012
    Location
    Canada
    Posts
    112

    Default Re: What kind of backups are available?

    Quote Originally Posted by Astralogic View Post
    I just realized that I''m not sure what the file path should be. The home folder that gets backed up isn't the actual folder called home is it? It's the folder with my user name which is inside the home folder. So it should be restored to /home. Is that right?

    backupFilePath
    is the path to the tar archive which contains the backup of your former home folder. This tar archive may have been created using the command line given in post #2, recalled bellow for convenience:

    Code:
    /$ tar --one-file-system -cWf backupFilePath "$HOME" --exclude="$HOME/.cache"
    A typical use case would be Tux wanting to backup up his home folder before re-installing openSUSE. First, he creates a tar archive containing all his data in an external hard drive partition called myHardDrive. The partition myHardDrive has been mounted to /run/media/tux/myHardDrive.

    Code:
    /$ tar --one-file-system -cWf /run/media/tux/myHardDrive/backup.tar /home/tux --exclude=/home/tux/.cache
    The resulting size of /run/media/tux/myHardDrive/backup.tar should be very close to the size of /home/tux.

    GNU tar implementation removes by default the leading / of tar archive members' path. So, if Tux had a file in his home folder which path was /home/tux/letter.txt, it would be stored in /run/media/tux/myHardDrive/backup.tar as home/tux/letter.txt. This is an important point to remember when restoring from a tar archive.

    Tux as finished to re-install openSUSE and have created a temporary user backupagent in order to restore his data with an unprivileged user. Using YaST he creates a new user called tux. He plugs in his external hard drive and mounts the myHardDrive partition to /run/media/backupagent/myHardDrive. He wants his former tux home folder to be restored in /home/tux, where the new tux home folder lies. Remembering that the leading / has been removed inside the tar archive, he needs to extract the contents of the tar archive from the root of the filesystem /:

    Code:
    /# tar -xf /run/media/backupagent/myHardDrive/backup.tar
    He runs the command as root so the permissions and ownership of his former home folder are also restored. Eventualy, he checks the ownership and permissions of /home/tux using ls:

    Code:
    $ ls -l /home/tux
    He see that /home/tux is owned by tux user and is assigned to users group. If it was otherwise, he could have corrected the ownership using chown:

    Code:
    # chown -R tux:users /home/tux
    I hope this use case made it clearer how tar can be used for backing up and restoring data. If you choose to take this use case as an example, please check the command lines before executing them. Chiefly those executed as root.
    Kalten

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •