WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to create a simple backup file tcz?  (Read 4600 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
How to create a simple backup file tcz?
« on: January 17, 2010, 03:29:06 PM »
In the past I created custom backup file tce extensions by simply using tar and renaming the file to ".tce".

Now I would like to do the same thing (load files to RAM on boot) using the "new" approach in tc v2.8rc3.

I get how to use the copy2fs.flg and copy2fs.lst but I'm not clear on how to create the tcz.  Are these the right steps?

Code: [Select]
mkdir /tmp/package
cp all backup files to /tmp/package
cd /tmp/package
mksquashfs package backup_name.tcz
mv backup_name.tcz ../tce/optional
ln -s ../tce/backup_name.tcz  ../tce/optional/backup_name.tcz
« Last Edit: January 17, 2010, 03:39:37 PM by bigpcman »
big pc man

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: How to create a simple backup file tcz?
« Reply #1 on: January 17, 2010, 03:45:27 PM »
The ln command has them the wrong way around, it should be "ln target linkname".
Otherwise that's it.
The only barriers that can stop you are the ones you create yourself.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: How to create a simple backup file tcz?
« Reply #2 on: January 17, 2010, 03:48:42 PM »
The ln command has them the wrong way around, it should be "ln target linkname".
Otherwise that's it.
I always seem to do that. Thanks
big pc man

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to create a simple backup file tcz?
« Reply #3 on: January 17, 2010, 03:56:04 PM »
No, it is 'ln source destination'.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: How to create a simple backup file tcz?
« Reply #4 on: January 17, 2010, 05:54:56 PM »
No, it is 'ln source destination'.

After thinking about it I missed an obvious part of the process. The backup files need to have  destinations established via a list! So here's another crack at what I think is required:
Code: [Select]
# Establish file backup list using tc builtin tool - add files one by one.
/usr/bin/add2file /tmp/backup_name.lst

# Create tar file from the list.
tar -C / -T /tmp/backup_name.lst -zcf /tmp/backup_name.tar.gz

mkdir /tmp/package

# unpack the tar in package/.
tar -xf /tmp/backup_name.tar.gz -C /tmp/package

# Create tcz file
mksquashfs /tmp/package backup_name.tcz

# Move the tcz and create link
mv /opt/package/backup_name.tcz ../tce/optional
ln -s ../tce/optional/backup_name.tcz ../tce/backup_name.tcz
« Last Edit: January 17, 2010, 06:23:02 PM by bigpcman »
big pc man

Offline vitex

  • Full Member
  • ***
  • Posts: 113
Re: How to create a simple backup file tcz?
« Reply #5 on: January 17, 2010, 06:42:16 PM »
There is no need to pack and unpack the files using tar; cpio in pass-through mode will copy files based on a list that is either in a file or is generated by a program such as find.

If you install GNU cpio (cpio.tcz), then the following should work assuming each file path begins with "/"

Code: [Select]
cpio -pud /tmp/package </tmp/backup-name.lst
Busybox (or GNU) cpio will work if you remove the initial "/" from each file path and execute

Code: [Select]
( cd / ; cpio -pud /tmp/package </tmp/backup-name.lst )
(Busybox cpio's pass-through mode handling of paths beginning with "/" will be fixed in an upcoming release.)

Also, you need to be in directory /tmp when you invoke mksquashfs if you refer to the directory as "package".

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: How to create a simple backup file tcz?
« Reply #6 on: January 17, 2010, 08:06:35 PM »
There is no need to pack and unpack the files using tar; cpio in pass-through mode will copy files based on a list that is either in a file or is generated by a program such as find.

If you install GNU cpio (cpio.tcz), then the following should work assuming each file path begins with "/"

Code: [Select]
cpio -pud /tmp/package </tmp/backup-name.lst
Busybox (or GNU) cpio will work if you remove the initial "/" from each file path and execute

Code: [Select]
( cd / ; cpio -pud /tmp/package </tmp/backup-name.lst )
(Busybox cpio's pass-through mode handling of paths beginning with "/" will be fixed in an upcoming release.)

Also, you need to be in directory /tmp when you invoke mksquashfs if you refer to the directory as "package".

Thanks for the tip. I have not been able to get busybox cpio to work. I tried:
Code: [Select]
root@box:/tmp# cat backup.lst
home/tc/.Xauthority
home/tc/.Xdefaults
home/tc/.ash_history

root@box:/tmp# cpio -pud package < backup.lst
cpio: home/tc/.Xauthority: No such file or directory

and

root@box:/tmp# cpio -pud /tmp/package < /tmp/ backup.lst

In all cases no files are transfered to /tmp/package.

I'll try ( cd / ; cpio -pud /tmp/package </tmp/backup-name.lst ) next.
« Last Edit: January 17, 2010, 08:13:34 PM by bigpcman »
big pc man

Offline vitex

  • Full Member
  • ***
  • Posts: 113
Re: How to create a simple backup file tcz?
« Reply #7 on: January 17, 2010, 08:45:03 PM »


Thanks for the tip. I have not been able to get busybox cpio to work. I tried:
Code: [Select]
root@box:/tmp# cat backup.lst
home/tc/.Xauthority
home/tc/.Xdefaults
home/tc/.ash_history

root@box:/tmp# cpio -pud package < backup.lst
cpio: home/tc/.Xauthority: No such file or directory

and

root@box:/tmp# cpio -pud /tmp/package < /tmp/ backup.lst

In all cases no files are transfered to /tmp/package.

I'll try ( cd / ; cpio -pud /tmp/package </tmp/backup-name.lst ) next.

If a file's path does not begin with "/", then cpio fetches the file relative to the current working directory.  Since you executed cpio in /tmp, you were telling cpio to fetch files from /tmp/home/tc/..., which does not exit.  Thus you need to use

Code: [Select]
( cd / ; cpio -pud ... )
so cpio executes in a subshell with "/" as its working directory.  (Using a subshell makes the change to "/" temporary for that command sequence.)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: How to create a simple backup file tcz?
« Reply #8 on: January 17, 2010, 09:03:52 PM »
If a file's path does not begin with "/", then cpio fetches the file relative to the current working directory.  Since you executed cpio in /tmp, you were telling cpio to fetch files from /tmp/home/tc/..., which does not exit.  Thus you need to use
Code: [Select]
( cd / ; cpio -pud ... )so cpio executes in a subshell with "/" as its working directory.  (Using a subshell makes the change to "/" temporary for that command sequence.)

Thank you vitex for that clarification. So perhaps this will work better for creating a tcz.
Code: [Select]

# Establish file backup list using tc builtin tool - add files one by one.
/usr/bin/add2file /tmp/backup_name.lst

# copy files with full path intact
( cd / ; cpio -pud /tmp/package < /tmp/backup_name.lst )

# Create tcz file
cd /tmp
mksquashfs package backup_name.tcz

# Move the tcz and create link
mv /tmp/package/backup_name.tcz ../tce/optional
ln -s ../tce/optional/backup_name.tcz ../tce/backup_name.tcz

All of this should be done as root user.

edit: I removed the "mkdir /tmp/package" command since cpio does this automatically. Also removed the erroneous leading cd /tmp.
« Last Edit: January 26, 2010, 08:49:35 PM by bigpcman »
big pc man